On Tue, Dec 11, 2012 at 4:10 PM, John Peterson
<peter...@cfdlab.ae.utexas.edu> wrote:
> On Tue, Dec 11, 2012 at 2:21 PM, John Peterson
> <peter...@cfdlab.ae.utexas.edu> wrote:
>> On Mon, Dec 10, 2012 at 5:04 PM, Kirk, Benjamin (JSC-EG311)
>> <benjamin.kir...@nasa.gov> wrote:
>>> libMesh users & developers:
>>>
>> Then the work flow is as follows:
>>
>> 1.) <finish work on branch_name>
>> 2.) git co master
>> 3.) git fetch
>> 4.) git merge origin/master
>> 5.) git co branch_name
>> 6.) git rebase master
>> 7.) git co master
>> 8.) git merge branch_name
>> 9.) git push
>
> As you might have hoped, this process can be simplified somewhat!
>
> Let's say you have made some commits on a branch named branch_name,
> it's currently checked out, and you want to pull down the most recent
> changes from github (similar to an svn up).
>
> You'd then just do
>
> git pull --rebase
>
> I should note that this is slightly dangerous.  It can fail if there
> are any conflicts, and I don't have enough experience to describe the
> process of fixing those and continuing on (but I will test that now).


So the process for resolving conflicts during pull --rebase is exactly
the same as it is during a normal rebase.  I'll discuss the steps
below if you want to play along at home:



1.) Generate a conflict on purpose: branch from the commit just prior
to the current HEAD, and on the new branch, create a commit that
deliberately conflicts with the most recent commit in master:
 a.) git co master
 b.) git co <previous hash>
 c.) git co -b test_branch
 d.) git co test_branch
 e.) <make commit which conflicts with most recent on master>
 f.) git pull --rebase https://github.com/libMesh/libmesh.git master



You should get something like the following error message:

> From https://github.com/libMesh/libmesh
>  * branch            master     -> FETCH_HEAD
> First, rewinding head to replay your work on top of it...
> Applying: Generate deliberate conflict before git pull --rebase.
> Using index info to reconstruct a base tree...
> Falling back to patching base and 3-way merge...
> Auto-merging README
> CONFLICT (content): Merge conflict in README
> Failed to merge in the changes.
> Patch failed at 0001 Generate deliberate conflict before git pull --rebase.
>
> When you have resolved this problem run "git rebase --continue".
> If you would prefer to skip this patch, instead run "git rebase --skip".
> To check out the original branch and stop rebasing run "git rebase --abort".
>
> ((64556fb...)|REBASE)$

In particular, note my prompt has been changed to tell me the current
hash and to let me know that I'm in the midst of a rebase.  You can do
this by sourcing the git completion and prompt files

https://raw.github.com/git/git/master/contrib/completion/git-completion.bash
https://raw.github.com/git/git/master/contrib/completion/git-prompt.sh

in your .bash_profile, and following the instructions therein.




2.) Run git status to see more about the nature of the problem

((64556fb...)|REBASE)$ git st

> # Not currently on any branch.
> # Unmerged paths:
> #   (use "git reset HEAD <file>..." to unstage)
> #   (use "git add/rm <file>..." as appropriate to mark resolution)
> #
> # both modified:      README




3.) So it tells us that both commits modified the README file!  Let's
   resolve the conflict.  Open up README in a text editor, the
   conflicts look the same way they did in SVN.  In one commit (the
   one from github) there is a blank line, while in my local branch I
   put 'aaa' on that same line, hence the conflict.

<<<<<<< HEAD
=======
aaa
>>>>>>> Generate deliberate conflict before git pull --rebase.




4.) Resolve the conflict by going with the version from HEAD (manually
deleting the conflict markers.)
5.) Now, re-add the file (don't forget this step!!)

((64556fb...)|REBASE)$ git add README




6.) Continue the rebasing

((64556fb...)|REBASE)$ git rebase --continue

In this particular case, we get another error:

> Applying: Generate deliberate conflict before git pull --rebase.
> No changes - did you forget to use 'git add'?
> If there is nothing left to stage, chances are that something else
> already introduced the same changes; you might want to skip this patch.
>
> When you have resolved this problem run "git rebase --continue".
> If you would prefer to skip this patch, instead run "git rebase --skip".
> To check out the original branch and stop rebasing run "git rebase --abort".

Oops, yes, git is correct.  After resolving the conflict, our patch is
now empty, so we should skip it!


7.) ((64556fb...)|REBASE)$ git rebase --skip


At this point your prompt should be back to normal.  If you have
multiple conflicts, you will deal with them one at a time in the same
manner.  If you get too confused, you can always back out of the whole
process with 'git rebase --abort'.

--
John

------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
_______________________________________________
Libmesh-devel mailing list
Libmesh-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libmesh-devel

Reply via email to