Git Lifecycle: Promote Your Work to the Master Branch

Every-day usage: at some point, you'll deem that what you've written is appropriate, useful, tested and stable. You'll be committing your work to your personal branch.

You also push your work to your personal branch's remote.

$ git push

Every-day usage: at some point, you'll deem that what you've written is appropriate, useful, tested and stable. You'll want to promote it all the way to branch master, i.e.: commit your work to deeper repository. You modify code, you do git add, git commit, etc., then push it back to master which will launch a continuous build (via Jenkins) and you move on to the next bug, task, project, etc.

You should use this sequence until you're very comfortable with the process.

$ git checkout master Switched to branch 'master' $ git merge jack* $ git push

* If Git replies "Already up-to-date.", this means that you haven't committed anything different from what's already there between jack and master.

If there's stuff you don't wish to commit...

If you're going to push all the way back to master, but you've got stuff in an unfinished state you don't want to send, you need to stash it. The stash is always personal, meaning you don't need to have checked out your personal repository–git stash is always relative to that.

  1. $ git add/rm/commit/etc.
  2. $ git stash save "This is stuff I don't want to push yet..." (saves that stuff)
  3. Do (or continue doing) your pushes.
  4. $ git stash apply (restores that unfinished stuff)
  5. $ git stash drop (drops any record of the stash)

Also, git stash has 4 very useful levels:

  1. git stsh     # stash only unstaged changes to tracked files
  2. git stash    # stash any changes to tracked files
  3. git staash   # stash untracked and tracked files
  4. git staaash # stash ignored, untracked, and tracked files