Menu

Git-Rebase-Workflow

Brad King Matthew J. Leotta
There is a newer version of this page. You can find it here.

VXL Rebase Git Workflow

Before starting with this workflow, make sure you have run the developer initialization script.

In the rebase workflow all work is done on the master branch. This workflow recommended for Git novices and is quite similar to the workflow used in Subversion and CVS.

Update

Update your local checkout of the master branch by downloading and applying the changes from the server (assumes a clean checkout with no local changes or commits).

$ git pull

Make Local Commits

Edit files and make commits. No network connection required. Repeat as many times as needed. Multiple small, targeted commits are preferred over a large commit with many changes.

$ edit file1 file2 file3
$ git add file1 file2 file3
$ git commit

Note that unlike in Subversion you need to add any files containing changes you want to commit, not just new files that were previously untracked.

Publish

When you are happy with your local commits, publish them back to the official repository

$ git push

Rebase

The above publish step will frequently fail because someone else has published changes first. Use the command below to get the latest upstream changes and apply your work on top. This is analogous to svn update. If you have multiple local commits, each one will be applied in sequence on top of the new upstream master.

$ git pull --rebase

When the rebase is successful try git push again to publish.

Resolve conflicts

If your changes conflict with the upstream master branch you will need to resolve conflicts. The above rebase command will apply each commit in sequence until it finds a conflict. When a conflict is found the rebase is paused on the conflicting commit to allow you to make a resolution. When all conflicts are resolved you resume the rebase and the remaining commits are applied. The rebase may interrupt again if additional commits contain conflicts.

When a conflict occurs use git status to see which files are conflicting. Conflicts are marked in the files in a similar way as in Subversion. Conflicting files need to be edited by hand or using a merge tool to resolve conflicts. Mark the conflict as resolved by adding the file and then continue the rebase.

$ edit conflict_file1 conflict_file2
$ git add conflict_file1 conflict_file2
$ git rebase --continue