Created
April 13, 2012 15:27
-
-
Save phatboyg/2377682 to your computer and use it in GitHub Desktop.
Git Usage
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git fetch origin | |
git checkout develop | |
git rebase origin/develop | |
-- this pulls any commits from the server (origin) to my local repository | |
-- checks out (switches to...) my local develop branch | |
-- aligns my develop branch to the origin/develop branch (cleans up history) | |
If I had an existin feature branch... | |
git checkout my_feature | |
git rebase develop | |
-- update my feature branch to have the same base/history as develop | |
-- incorporates any changes by other devs, etc. into my feature branch | |
-- keeps my local feature branch up to date to avoid "the big merge" syndrome | |
To create a new feature branch | |
git checkout develop | |
git checkout -b my_feature_branch | |
-- we check out develop to start branch from known develop state | |
-- we create a branch with "-b" using checkout to switch to it immediately | |
As I make changes and want to commit files | |
git add --all . (from the root of the repo is best, but anywhere CAN work, '.' is current directory) | |
git commit -m "My commit message here" | |
--or I can do "git commit" and then use my configured editor to type the commit message | |
To merge a feature branch into the develop branch: | |
git checkout develop (after committing all changes to the branch, of course) | |
git merge --ff-only my_feature_branch | |
-- this will do a fast-forward only merge into the develop branch from the source feature branch | |
-- if the branch cannot be fast forwarded, the branch likely needs rebased against develop as | |
-- shown above | |
To push our changes to the remote develop branch | |
git push origin develop | |
-- if we get an error, someone else has likely committed ahead of us, and we need to do | |
-- the fetch/rebase/merge/push dance once again (so get quick at it) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
awesome, Thanks!