Skip to content

Instantly share code, notes, and snippets.

@phatboyg
Created April 13, 2012 15:27
Show Gist options
  • Save phatboyg/2377682 to your computer and use it in GitHub Desktop.
Save phatboyg/2377682 to your computer and use it in GitHub Desktop.
Git Usage
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)
@dominiqueplante
Copy link

awesome, Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment