- 27/10/2014 : https://www.codeschool.com/account/courses/git-real
- Git aliases: Extended version here : https://git.wiki.kernel.org/index.php/Aliases
git push origin :branchname
: remove a remote branchgit rebase
: Tidy commit history. Remove merge commitsgit prune
: Clean up stale local branches when compared to remote
- git rebase
- git merge conflicts
- git flow and github gitflow : Atlassian, Vincent Driessen
- git shortcuts: Mislav Maronic
Tips: Origin/master is actually a branch that merges automatically with git pull
git diff --staged
: diff on staging area
git reset --soft HEAD^
: reset changes to 1 commit before HEAD
git reset --soft HEAD^^
: reset changes to 2 commits before HEAD
git remote add <name> <address>
: add a remote
git push -u origin master
: push changes and set upstream
git checkout -b admin
: create, checkout branch with name 'admin'
HINT: Create a branch and send to remote if your using it more than a day
git branch -r
: list all remote branches
git remote show origin
: show origin branches
git branch -r
: lists all remote branches
git remote prune origin
: remove any stale local branches
git push origin staging:master
: *** pushes all changes in local 'staging' branch to the remote 'master' branch ***
```git push origin :weasel`` : delete a remote branch named 'weasel'
git tag -a v1.3.1 -m "Tagged to release 1.3.1"
: Create a tag with a message
Removes merge commit messages Applies changes specified changes above the existing timeline Use git rebase and git rebase --continue in merge conflicts
git log --oneline
: shows you each commit on oneline
git log --oneline --graph
: shows you a graph
git log -p
: shows all file changes in a similar fashion to git diff
git log --until=1.minute.ago
git log --since=1.day.ago
git log --since=1.hour.ago
git log --since=1.month.ago --until=2.weeks.ago
git log --since=2000-01-01 --until=2012-12-21
git diff HEAD^
: parent of latest commit
git diff HEAD^^
: grandparent of latest commit
git diff HEAD~5
: five commits ago
git diff HEAD^..HEAD
: second most recent commit vs. most recent commit
git diff 321232..32123
: compare two SHA
git blame <filename> --date short
: shows line by line who made file changes and when
.git/info/exclude : store local files without including in the repo
git rm --cached <filename>
: removes tracking, but not the local file. combine with .gitignore and then commit
We can setup aliases on the git global level to make life easier (and without using bash aliases)
git config --global alias.<aliasname> \ <command to alias>
example: git config --global alias.mylog \ "log --graph --decorate --pretty=online --abbrev-commit --all"