-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Git Gotchas and Tips
Developing for YUI will lead you to deal with git
quite often. The purpose of this page is to list several git
gotchas as well as offer tips for using git
with YUI. If you run into any "gotchas" please feel free to add to the list!
Without an explicit , git branch
and git checkout -b
default to HEAD - which is the branch you are currently on (not necessarily master
).
So for :
$ git checkout topic-branch-one
$ git checkout -b topic-branch-two
--> topic-branch-two
would be created off of topic-branch-one
, not master
.
To specify which branch you would include another argument like:
$ git checkout topic-branch-one
$ git checkout -b topic-branch-three master
--> topic-branch-three
branched from master
instead of topic-branch-one
##Fundamentals
-
A branch is a parallel set of commits from an existing commit.
-
git branch foo <commit>
starts this branch,foo
, from -
Everything else is just different ways to specify (as with most things in git).
git branch foo
startsfoo
from whichever commit you're on currently (aka HEAD - normally the tip of your checked out branch).git branch foo upstream/bar
startsfoo
from the commit referenced by upstream/bar, which is the tip of thebar
branch, on the remote called 'upstream'.git branch foo bar
startsfoo
from the commit referenced bybar
, which is the tip of your localbar
branch (which may or may not be different from the upstream/bar commit. In fact your bar may have nothing to do with upstream/bar) -
And sugar on top of
git branch
+git checkout
git checkout -b foo
is the same asgit branch foo; git checkout foo;
git checkout -b foo upstream/bar
is the same asgit branch foo upstream/bar; git checkout foo;
YUI Engineer Derek Gathright created a simple shell script to help YUI developers stay up-to-date with all the various branches in YUI. yui-sync.sh
You should include in your .bash_profile
(or equiv) a script like this one that displays the current git branch whenever you are inside a repo.
2