Jump to content

I accidentally pushed another git folder to my git repo. Now I want to revert it back

mrchow19910319

So here’s the problem, I have one folder called A that I store my project in. And this folder had its own git repo called: repo-A. In order to test some feature I wanted to add in, I created a clone of folder A, called B.

And after I’ve done adding in all features I want to add in, I pushed folder B into my repo-A. Now I want to revert it back to its last state.

I couldn’t understand all the online tutorials about git revert or git reset.

What procedures should I follow.'

 

1661903296_Image1.png.19c80753606331fc64112c4bc5af5c18.png

If it is not broken, let's fix till it is. 

Link to comment
Share on other sites

Link to post
Share on other sites

8:34:30 PM: Build ready to start
8:34:32 PM: build-image version: 9e0f207a27642d0115b1ca97cd5e8cebbe492f63
8:34:32 PM: build-image tag: v3.3.2
8:34:32 PM: buildbot version: 89a70647dd4caa4f3273ade0957c10d63327cb10
8:34:33 PM: Fetching cached dependencies
8:34:33 PM: Starting to download cache of 255.0KB
8:34:33 PM: Finished downloading cache in 75.656927ms
8:34:33 PM: Starting to extract cache
8:34:33 PM: Failed to fetch cache, continuing with build
8:34:33 PM: Starting to prepare the repo for build
8:34:33 PM: No cached dependencies found. Cloning fresh repo
8:34:33 PM: git clone https://github.com/zhouxiang19910319/slowpacedcoding_gatsby
8:34:34 PM: Preparing Git Reference refs/heads/master
8:34:34 PM: Starting build script
8:34:34 PM: Installing dependencies
8:34:36 PM: Downloading and installing node v10.16.3...
8:34:36 PM: Downloading https://nodejs.org/dist/v10.16.3/node-v10.16.3-linux-x64.tar.xz...
8:34:36 PM: 
##################################
8:34:36 PM:                               47.6%
8:34:36 PM: 
##########################################
8:34:36 PM: ############################## 100.0%
8:34:36 PM: Computing checksum with sha256sum
8:34:36 PM: Checksums matched!
8:34:39 PM: Now using node v10.16.3 (npm v6.9.0)
8:34:39 PM: Attempting ruby version 2.6.2, read from environment
8:34:40 PM: Using ruby version 2.6.2
8:34:40 PM: Using PHP version 5.6
8:34:40 PM: Started restoring cached node modules
8:34:40 PM: Finished restoring cached node modules
8:34:40 PM: Started restoring cached yarn cache
8:34:40 PM: Finished restoring cached yarn cache
8:34:40 PM: Installing yarn at version 1.17.0
8:34:40 PM: Installing Yarn!
8:34:40 PM: > Downloading tarball...
8:34:40 PM: [1/2]: https://yarnpkg.com/downloa
8:34:40 PM: ds/1.17.0/yarn-v1.17.0.tar.gz --> /tmp/yarn.tar.gz.9ua7uQn4vJ
8:34:40 PM:   % Total    % Received % Xferd  Avera
8:34:40 PM: ge Speed   Time    Time     Time  Current
8:34:40 PM:             Dload  Upload   Tota
8:34:40 PM: l   Spent    Left  Speed
8:34:40 PM: 
  0     0    0     0    0
8:34:40 PM:   0      0      0 --:--:-- --:--:-- --:--:--     0
8:34:40 PM: 
  0     0    0     0    0     0      0      0 --:--:--
8:34:40 PM: --:--:-- --:--:--     0
8:34:40 PM: 
100    93  100    93    0     0
8:34:40 PM:   375      0 --:--:-- --:--:-- --:--:--   375
8:34:41 PM: 
100   609    0   609    0     0    962      0 --:--:-- --:--:-- --:--:-
8:34:41 PM: -   962
8:34:41 PM: 
100 1213k  100 1213k    0     0  1151k      0  0:00:01  0:00:01
8:34:41 PM:  --:--:-- 1151k
8:34:41 PM: [2/2]: https://yarnpkg.com/downloads/1.17.0/yarn-v1
8:34:41 PM: .17.0.tar.gz.asc --> /tmp/yarn.tar.gz.9ua7uQn4vJ.asc
8:34:41 PM: 
100    97  100    97    0     0   2391      0 --:--:-- --:-
8:34:41 PM: -:-- --:--:--  2391
8:34:41 PM: 
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --
8:34:41 PM: :--:--     0
100   613    0   613    0     0   2995      0 --:--:-- --:--:-- --:--:--  598k
8:34:41 PM: 
100   832  100   832    0     0   3437      0 --:--:-- -
8:34:41 PM: -:--:-- --:--:--  3437
8:34:42 PM: > Verifying integrity...
8:34:42 PM: gpg: Signature made Fri 14 Jun 2019 06:55:58 PM UTC using RSA key ID 69475BAA
8:34:42 PM: gpg: Good signature from "Yarn Packaging <yarn@dan.cx>"
8:34:42 PM: gpg: WARNING: This key is not certified with a trusted signature!
8:34:42 PM: gpg:          There is no indication that the signature belongs to the owner.
8:34:42 PM: Primary key fingerprint: 72EC F46A 56B4 AD39 C907  BBB7 1646 B01B 86E5 0310
8:34:42 PM:      Subkey fingerprint: 6D98 490C 6F1A CDDD 448E  4595 4F77 6793 6947 5BAA
8:34:42 PM: > GPG signature looks good
8:34:42 PM: > Extracting to ~/.yarn...
8:34:42 PM: > Adding to $PATH...
8:34:42 PM: > We've added the following to your /opt/buildhome/.profile
8:34:42 PM: > If this isn't the profile of your current shell then please add the following to your correct profile:
8:34:42 PM: export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH"
8:34:42 PM: 
8:34:42 PM: > Successfully installed Yarn 1.17.0! Please open another terminal where the `yarn` command will now be available.
8:34:43 PM: Installing NPM modules using Yarn version 1.17.0
8:34:44 PM: yarn install v1.17.0
8:34:44 PM: warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
8:34:44 PM: [1/4] Resolving packages...
8:34:52 PM: [2/4] Fetching packages...
8:35:14 PM: info fsevents@2.0.7: The platform "linux" is incompatible with this module.
8:35:14 PM: info "fsevents@2.0.7" is an optional dependency and failed compatibility check. Excluding it from installation.
8:35:14 PM: info fsevents@1.2.9: The platform "linux" is incompatible with this module.
8:35:14 PM: info "fsevents@1.2.9" is an optional dependency and failed compatibility check. Excluding it from installation.
8:35:14 PM: info fsevents@1.2.4: The platform "linux" is incompatible with this module.
8:35:14 PM: info "fsevents@1.2.4" is an optional dependency and failed compatibility check. Excluding it from installation.
8:35:14 PM: [3/4] Linking dependencies...
8:35:14 PM: warning " > bootstrap@4.3.1" has unmet peer dependency "jquery@1.9.1 - 3".
8:35:14 PM: warning " > bootstrap@4.3.1" has unmet peer dependency "popper.js@^1.14.7".
8:35:14 PM: warning "gatsby > eslint-config-react-app@4.0.1" has incorrect peer dependency "eslint-plugin-flowtype@2.x".
8:35:14 PM: warning "gatsby > @typescript-eslint/eslint-plugin > tsutils@3.17.1" has unmet peer dependency "typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta".
8:35:14 PM: warning "gatsby-plugin-sass > sass-loader@7.3.1" has unmet peer dependency "webpack@^3.0.0 || ^4.0.0".
8:35:14 PM: warning " > gatsby-plugin-typography@2.3.8" has unmet peer dependency "typography@^0.16.0 || ^1.0.0-alpha.0".
8:35:32 PM: [4/4] Building fresh packages...
8:35:39 PM: success Saved lockfile.
8:35:39 PM: Done in 55.87s.
8:35:39 PM: NPM modules installed using Yarn
8:35:40 PM: Started restoring cached go cache
8:35:40 PM: Finished restoring cached go cache
8:35:40 PM: unset GOOS;
8:35:40 PM: unset GOARCH;
8:35:40 PM: export GOROOT='/opt/buildhome/.gimme/versions/go1.12.linux.amd64';
8:35:40 PM: export PATH="/opt/buildhome/.gimme/versions/go1.12.linux.amd64/bin:${PATH}";
8:35:40 PM: go version >&2;
8:35:40 PM: export GIMME_ENV='/opt/buildhome/.gimme/env/go1.12.linux.amd64.env';
8:35:40 PM: go version go1.12 linux/amd64
8:35:40 PM: Installing missing commands
8:35:40 PM: Verify run directory
8:35:40 PM: Executing user command: gatsby build
8:35:42 PM: success open and validate gatsby-configs — 0.063
8:35:44 PM: success load plugins — 1.114
8:35:44 PM: success onPreInit — 0.019
8:35:44 PM: success delete html and css files from previous builds — 0.018
8:35:44 PM: success initialize cache — 0.018
8:35:44 PM: success copy gatsby files — 0.044
8:35:44 PM: success onPreBootstrap — 0.286
8:35:44 PM: success source and transform nodes — 0.240
8:35:44 PM: success Add explicit types — 0.021
8:35:44 PM: success Add inferred types — 0.160
8:35:45 PM: success Processing types — 0.129
8:35:45 PM: success building schema — 0.382
8:35:45 PM: success createPages — 0.165
8:35:45 PM: success createPagesStatefully — 0.111
8:35:45 PM: success onPreExtractQueries — 0.016
8:35:45 PM: success update schema — 0.031
8:35:45 PM: success extract queries from components — 0.367
8:35:45 PM: success write out requires — 0.025
8:35:45 PM: success write out redirect data — 0.077
8:35:45 PM: node: symbol lookup error: /opt/build/repo/node_modules/sharp/build/Release/sharp.node: undefined symbol: _ZNK4vips6VImage7pngsaveEPcPNS_7VOptionE
8:35:45 PM: Skipping functions preparation step: no functions directory set
8:35:45 PM: Caching artifacts
8:35:45 PM: Started saving node modules
8:35:45 PM: Finished saving node modules
8:35:45 PM: Started saving yarn cache
8:35:45 PM: Finished saving yarn cache
8:35:45 PM: Started saving pip cache
8:35:45 PM: Finished saving pip cache
8:35:45 PM: Started saving emacs cask dependencies
8:35:45 PM: Finished saving emacs cask dependencies
8:35:45 PM: Started saving maven dependencies
8:35:46 PM: Finished saving maven dependencies
8:35:46 PM: Started saving boot dependencies
8:35:46 PM: Finished saving boot dependencies
8:35:46 PM: Started saving go dependencies
8:35:46 PM: Finished saving go dependencies
8:35:48 PM: Error running command: Build script returned non-zero exit code: 127
8:35:48 PM: Failing build: Failed to build site
8:35:48 PM: failed during stage 'building site': Build script returned non-zero exit code: 127
8:35:48 PM: Finished processing build request in 1m15.500829884s

 

If it is not broken, let's fix till it is. 

Link to comment
Share on other sites

Link to post
Share on other sites

These links explain it quite well:

https://www.atlassian.com/git/tutorials/undoing-changes/git-revert

https://www.atlassian.com/git/tutorials/undoing-changes/git-reset

https://www.atlassian.com/git/tutorials/resetting-checking-out-and-reverting

 

I didn't really understand what you have done. When you say push I assume you have a remote repo? Is folder B inside folder A? Did you push folder A or B to the remote repo? What do you want the end result to be? 

 

Regardless, it doesn't sound like you are using git as intended. Normally you would create a new branch to test some feature and then merge into master. Also, having many different copies of the same repo locally kind of defeats the purpose of a version control system. Lastly, I think it would be a good idea to create a dummy project so that you can experiment with adding new files, commits, branches, merging and all of that so that you can get the hang of it without having to deal with 300mb of node modules ;) 

Link to comment
Share on other sites

Link to post
Share on other sites

23 hours ago, Umberto said:

These links explain it quite well:

https://www.atlassian.com/git/tutorials/undoing-changes/git-revert

https://www.atlassian.com/git/tutorials/undoing-changes/git-reset

https://www.atlassian.com/git/tutorials/resetting-checking-out-and-reverting

 

I didn't really understand what you have done. When you say push I assume you have a remote repo? Is folder B inside folder A? Did you push folder A or B to the remote repo? What do you want the end result to be? 

 

Regardless, it doesn't sound like you are using git as intended. Normally you would create a new branch to test some feature and then merge into master. Also, having many different copies of the same repo locally kind of defeats the purpose of a version control system. Lastly, I think it would be a good idea to create a dummy project so that you can experiment with adding new files, commits, branches, merging and all of that so that you can get the hang of it without having to deal with 300mb of node modules ;) 

I have a remote repo that is linked to folder A. And folder B is not inside of folder A.

I pushed B to the repo that is linked to A.

 

 

If it is not broken, let's fix till it is. 

Link to comment
Share on other sites

Link to post
Share on other sites

On 9/21/2019 at 1:01 AM, Umberto said:

 

 

1.png.c6378013653357280989923286d8f3c6.png

If it is not broken, let's fix till it is. 

Link to comment
Share on other sites

Link to post
Share on other sites

Wouldn't simply finding the last know good commit's id and resetting the repo to it be enough? Ie. git reset --hard yourcommitidhere followed by git --force push

Hand, n. A singular instrument worn at the end of the human arm and commonly thrust into somebody’s pocket.

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×