-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathxbga.txt
29 lines (29 loc) · 1.55 KB
/
xbga.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
Undoing a Merge
Assume we have gone through some massive merge
because someone on your team hasn’t committed in a while,
or you have a branch that was created some time ago
but hasn’t been rebasing and you want to pull it in.
So you try to git merge old_branch it and you get conflict after conflict
and it is just too much trouble to deal with and you just want to undo it all.
This is where git reset comes in.
To reset your working directory and index back to what it was before you tried the merge,
simply run:
$ git reset --hard HEAD
The —hard makes sure both your index file and working directory are changed to match what it used it be.
By default it will only reset your index,
leaving the partially merged files in your working directory.
If you happen to have worked through it all and committed,
then decided that it was a mistake because all of your tests break or something,
you can still go back
(and throw away that commit)
by running:
$ git reset --hard ORIG_HEAD
This is only helpful if you want to undo the latest change or changes.
If you happen to commit again then decide that you want to keep the latest commit,
but undo a commit that was added sometime before that,
you’ll need to use git revert,
which is a bit too dangerous to cover here.
• git branch (http://www.kernel.org/pub/software/scm/git/docs/git-branch.html)
• git merge (http://www.kernel.org/pub/software/scm/git/docs/git-merge.html)
• git reset (http://www.kernel.org/pub/software/scm/git/docs/git-reset.html)
• git revert (http://www.kernel.org/pub/software/scm/git/docs/git-revert.html)