Skip to content

Instantly share code, notes, and snippets.

@svenmueller
Last active December 24, 2015 11:38
Show Gist options
  • Save svenmueller/6791882 to your computer and use it in GitHub Desktop.
Save svenmueller/6791882 to your computer and use it in GitHub Desktop.
Some notes from our GIT session today...

Workflows

Story/Feature/Bugfix etc.

  • create a feature/bugfix branch to work on
$ git branch -b feature/scene7viewer   # create branch
$ git branch feature/scene7viewer      # switch to branch

$ git checkout -b feature/scene7viewer # create and checkout branch with one command

  • commit on branch
  • sync branch with remote repository
$ git push origin feature/scene7viewer  # push branch to remote repository
$ git pull origin feature/scene7viewer  # fetch from remote repository and merge

  • sync branch with master
$ git rebase master

  • merge branch into master (pull request)
$ git checkout master               # switch to master
$ git merge feature/scene7viewer    # simple merge (fast-forward)

  • delete branch
$ git branch -d feature/scene7viewer      # delete branch in local repository
$ git push origin :feature/scene7viewer   # delete branch in remote repository

Misc

Manpages

$ man git

Use help for git commands

$ git branch -h
$ git branch --help

Reset

$ git reset --hard HEAD # reset working directory and index
$ git reset --soft HEAD # reset index

Commit History

$ git log index.html        # show commit logs
$ git shortlog index.html   # show commit log summaries

Comparing

$ git diff master..feature/scene7viewer   # show differences betwen the two branches
$ git diff HEAD^1 index.html              # show differences between current and previos version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment