summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAchilleas Pipinellis <axilleas@axilleas.me>2016-02-05 00:43:56 +0200
committerAchilleas Pipinellis <axilleas@axilleas.me>2016-02-05 00:43:56 +0200
commitd516db9e7dd359adedb882f5e672627262284e18 (patch)
tree2a7163869bf253aab6acdcbbd053a95b2218c4c9
parent42e0e35784de81d2a0f7bff05870ddc5c531d0bb (diff)
downloadgitlab-ce-tutorials_git_tricks.tar.gz
First draft on Git tricks tutorialtutorials_git_tricks
[ci skip]
-rw-r--r--doc/tutorials/git_tricks.md98
1 files changed, 98 insertions, 0 deletions
diff --git a/doc/tutorials/git_tricks.md b/doc/tutorials/git_tricks.md
new file mode 100644
index 00000000000..2c4a388426a
--- /dev/null
+++ b/doc/tutorials/git_tricks.md
@@ -0,0 +1,98 @@
+Based on https://gitlab.com/gitlab-org/gitlab-ce/issues/5986 here is an outline.
+
+---
+
+A pack of Git tricks that will leverage your Git-fu.
+
+## Introduction
+
+
+## Oh-my-zsh Git plugin
+
+- https://github.com/robbyrussell/oh-my-zsh/wiki/Plugin:git
+- https://github.com/robbyrussell/oh-my-zsh/blob/master/plugins/git/git.plugin.zsh
+
+## Git extras
+
+Enhance Git with more commands
+
+- https://github.com/tj/git-extras
+
+## Aliases
+
+```ini
+[alias]
+ lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset' --abbrev-commit --date=relative
+ lol = log --graph --decorate --pretty=oneline --abbrev-commit
+```
+
+## `.gitconfig` on steroids
+
+- https://github.com/thoughtbot/dotfiles/blob/master/gitconfig
+- https://github.com/thoughtbot/dotfiles/pull/377
+
+---
+
+1. Set a global `.gitignore`:
+
+ ```ini
+ [core]
+ excludesfile = /home/user/.gitignore
+ ```
+
+1. Delete local branches that have been removed from remote on fetch/pull:
+
+ ```ini
+ [fetch]
+ prune = true
+ ```
+
+1. Gives you extra info when using Git submodules:
+
+ ```ini
+ [status]
+ submodulesummary = 1
+ ```
+
+## Misc
+
+1. Get a list of Git branches, ordered by most recent commit:
+
+ ```
+ git for-each-ref --sort=-committerdate refs/heads/
+ ```
+
+1. `@` is the same as `HEAD`:
+
+ ```
+ git show @~3
+ ```
+
+1. `-` refers to the branch you were on before the current one.
+ Use it to checkout the previous branch ([source][dash]):
+
+ ```sh
+ % git branch
+ master
+ * rs-zenmode-refactor
+
+ % git checkout master
+
+ % git checkout -
+ ```
+
+1. Delete local branches which have already been merged into master
+ ([source][del-merged]):
+
+ ```
+ git branch --merged master | grep -v "master" | xargs -n 1 git branch -d
+ ```
+
+1. Delete all stale tracking branches for a remote:
+
+ ```
+ git remote prune origin
+ ```
+
+[del-merged]: http://stevenharman.net/git-clean-delete-already-merged-branches
+[dash]: https://twitter.com/holman/status/530490167522779137