Typical Git workflow

j416 edited this page Sep 13, 2010 · 10 revisions

Download and install Git

In Linux distributions that’s usually just yum install git or
apt-get install git. See GitHub
if you’re on Windows or Mac.

Cloning repository

Go to the folder which will contain the clone, then type:

git clone git://github.com/bard/sameplace.git

Create your own local branch

Creating a local branch lets you make changes, compare with main
branch, and generate patches.

To create the branch:

git branch fix_for_foobar

To switch to it:

git checkout fix_for_foobar

Making changes

When you’re satisfied with the changes, you’ll want to commit them to
your local branch. Keep in mind that, differently than SVN or CVS,
“committing” doesn’t mean copying stuff from your working copy to the
central repository, instead you’ll be copying stuff from your working
copy to a branch in your local repository. We’ll see later how to get
that into the remote repository too.

To commit changes to local branch:

git commit -a -m 'Join Room Dialog: foobar functionality was broken.  Fixed.'

Preparing the patch

First, you’ll want to make sure that you’ll be producing a patch
against the most recent version of the central repository, so switch
to the master branch and update it:

git checkout master
git pull

Next, tell git to apply your local commits on top of the renewed master:

git rebase fix_for_foobar

Hint to author: The above will rebase master on top of fix_for_foobar, not the other way round.

Finally, create the patch. A file with the name derived from the commit message will be created:

git format-patch origin

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.