简体   繁体   中英

pull from git before particular commit id

I have one commit id which might have caused the issue. Is there any way I can pull from git before that commit id?

Let's say abc is my commit id, then I want to pull from git before commit id abc .

git fetch origin {commitID}:refs / remotes / origin / foo-commit

then I want to pull from git before commit id abc

You can git checkout abc~1 when your branch is up-to-date. To switch back, just git checkout branch .

I have one commit id which might have caused the issue.

So, your current commit is broken and you want to track down the issue? I think you might take a look at git bisect as well. For example:

git bisect start HEAD v1.0.0
Bisecting: x revision(s) left to test after this (roughly x step(s))

HEAD is broken; v1.0.0 is the last commit you know was functioning. Assume in-between were 10 commits. Git will then automatically detach your HEAD to the 5th (that is, check out that commit). You then can perform some tests and tell git if the commit is good or bad:

git bisect good/bad

Continuing with that, when you marked it bad, git will checkout, say, the 2nd commit, else the 7th etc. At some point, git will tell you hash is the first bad commit . This is an automatic approach for manually checking out commits to track down issues. It is also possible to run a script to test commits, eg: git bisect run ./test.sh . Aborting the bisecting section can be done using git bisect reset .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM