Difference between revisions of "TubeTK/Development/GITCheatSheet"

From KitwarePublic
Jump to navigationJump to search
Line 49: Line 49:
* git log --stat --summary  ( To see overview  )
* git log --stat --summary  ( To see overview  )


= Three ways to commit to remote/master =
# Without branching    ( Good for quick changes )
# Branching and merging 
# Branching and rebasing
= Additional References =
= Additional References =
* GIT tutorial [http://www.kernel.org/pub/software/scm/git/docs/gittutorial.html]
* GIT tutorial [http://www.kernel.org/pub/software/scm/git/docs/gittutorial.html]

Revision as of 20:18, 5 February 2010

Create a checkout


Stash local changes temporarily

  • git stash

Create a local branch

  • git branch test

Swtich to a local branch

  • git checkout test

Get stashed local changes

  • git stash pop

Update a branch to the remote master's head

  • git stash
  • git rebase origin master
  • git stash pop

Add to local commit

  • git add <filename>
  • git add -A

Push local commit

  • git push origin master

Remove a local branch

  • git checkout master
  • git branch -d <branch>

Track a remote branch

  • "git fetch" (get up to date) or "git pull"
  • git branch --track somebranch origin/somebranch
    • --track is not needed unless you've set branch.autosetupmerge to false in your config
  • git checkout somebranch
  • git commit
  • git push
    • sends changes to origin/somebranch

Delete a remote branch

  • Don't do this unless you're incredibly confident in what you're doing
  • git push origin :somebranch

Project History

  • git log ( To view the history of your changes )
  • git log -p ( To see complete diffs at each step )
  • git log --stat --summary ( To see overview )

Three ways to commit to remote/master

  1. Without branching ( Good for quick changes )
  2. Branching and merging
  3. Branching and rebasing

Additional References

  • GIT tutorial [1]