开发者

simple checkout in git?

开发者 https://www.devze.com 2023-04-12 09:28 出处:网络
I am experimenting with branching on git and running into nightmare after nightmare.Anyway, the current issue is that I wanted to merge the master into the branch.I tried \"git rebase\" because some s

I am experimenting with branching on git and running into nightmare after nightmare. Anyway, the current issue is that I wanted to merge the master into the branch. I tried "git rebase" because some site recommended that, and it did a number of destructive things but definitely did NOT merge my trunk into the branch. It actually blew up everything quite horribly and created all kinds of complicated merge errors and I cannot figure out how to simply revert my code to where it was before.

My question is twofold:

1) How do I make git completely revert to the point just before the git rebase? Everything I try gives me all kinds of headaches about merge errors. I don't want to merge anything. I just want to take a specific revision exactly as it was and make that the HEAD.

2) Once I get the mess cleaned up, how do I merge a tru开发者_开发百科nk into a branch? For what it's worth, the merge should not be all that complicated in terms of conflicts.


  1. Try git reset --hard to throw out the changes (including conflicts) in the working directory and reset your branch to its pre-merge-attempt state.

  2. From the branch you want to merge into, use git merge <other branch>. If there are conflicts, resolve them by opening the files and merging the lines between the <<<<< and >>>>> conflict markers, then git add <merged file>. When you have manually resolved all the conflicts, git commit to finish the merge.


If you're in the middle of a rebase, and you find that you can't fix the conflicts that arise, you can always abort the rebase with:

git rebase --abort

... which will restore your branch to its state before you started the rebase.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号