Skip to content

Instantly share code, notes, and snippets.

@alexandervantrijffel
Last active September 5, 2016 13:59
Show Gist options
  • Save alexandervantrijffel/2d0a09b1533b35f59bd8 to your computer and use it in GitHub Desktop.
Save alexandervantrijffel/2d0a09b1533b35f59bd8 to your computer and use it in GitHub Desktop.
Github cheatsheet - https://github.com/tiimgreen/github-cheat-sheet
Gitflow - https://github.com/nvie/gitflow
# view git status with correct renames info
git commit --dry-run -a
# benefits of Git over TFS: http://www.continuousimprover.com/2015/06/why-you-should-abandon-tfs-source.html
reference local directory on Windows
git clone file:///c:/users/lex/Dropbox/git/Synth
compare staged with HEAD
git diff --staged
# create new branch
git branch myfeature
git checkout myfeature
git add -A . && git commit -m "My first feature commit"
git checkout master
git merge --no-ff myfeature
# abort merge conflict resolution
git merge --abort
# checkout mybranch from origin/mybranch and create locally
git checkout mybranch
# view commit tree
git log --graph --oneline
git config --global color.ui auto
Git branching strategy
http://nvie.com/posts/a-successful-git-branching-model/
feature branch
$ git checkout -b myfeature develop
merge feature with develop branch
$ git checkout develop
Switched to branch 'develop'
$ git merge --no-ff myfeature
Updating ea1b82a..05e9557
(Summary of changes)
$ git branch -d myfeature
Deleted branch myfeature (was 05e9557).
$ git push origin develop
release branch
$ git checkout -b release-1.2 develop
Switched to a new branch "release-1.2"
$ ./bump-version.sh 1.2
Files modified successfully, version bumped to 1.2.
$ git commit -a -m "Bumped version number to 1.2"
[release-1.2 74d9424] Bumped version number to 1.2
1 files changed, 1 insertions(+), 1 deletions(-)
merge feature branch into master
$ git checkout master
Switched to branch 'master'
$ git merge --no-ff release-1.2
Merge made by recursive.
(Summary of changes)
$ git tag -a 1.2
merge release branch to develop
$ git checkout develop
Switched to branch 'develop'
$ git merge --no-ff release-1.2
Merge made by recursive.
(Summary of changes)
delete release branch
$ git branch -d release-1.2
Deleted branch release-1.2 (was ff452fe).
push new local branch to remote
git push -u origin mynewbranch
view previous version of file
git show HEAD~4:path/to/file
setup proxy for connecting to github behind a firewall
git config --global https.proxy https://DOMAIN\USERNAME:PASSWORD@PROXYFQDN:8080
git config --global http.proxy http://DOMAIN\USERNAME:PASSWORD@PROXYFQDN:8080
git config --global http.sslverify false
# cleanup git
git gc --auto
# removes staged and working directory changes
git reset --hard
# remove untracked
git clean -f -d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment