Skip to content

Instantly share code, notes, and snippets.

@veeeeeeeeeee
Last active March 22, 2018 05:42
Show Gist options
  • Save veeeeeeeeeee/4a4bb565e549c35c90641e653d43bbd6 to your computer and use it in GitHub Desktop.
Save veeeeeeeeeee/4a4bb565e549c35c90641e653d43bbd6 to your computer and use it in GitHub Desktop.
git stuffs
[alias]
lg = !"git lg1"
lg1 = !"git lg1-specific --all"
lg2 = !"git lg2-specific --all"
lg3 = !"git lg3-specific --all"
lg1-specific = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(auto)%d%C(reset)'
lg2-specific = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(auto)%d%C(reset)%n'' %C(white)%s%C(reset) %C(dim white)- %an%C(reset)'
lg3-specific = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset) %C(bold cyan)(committed: %cD)%C(reset) %C(auto)%d%C(reset)%n'' %C(white)%s%C(reset)%n'' %C(dim white)- %an <%ae> %C(reset) %C(dim white)(committer: %cn <%ce>)%C(reset)'
###### remote
git remote rm my_remote
###### creds
git config credential.helper cache
git config credential.helper 'cache --timeout=300'
###### branches
#list
git branch
#create branch
git branch my_branch
#delete branch
git branch -d my_to_delete_branch
#force delete branch
git branch -D my_to_delete_branch
#rename current branch
git branch -m my_new_branch_name
#checkout
git checkout my_other_branch
#create and checkout
git checkout -b my_new_branch
#sample
git branch my_new_feature
git checkout my_new_feature
git add some_files
git commit -m "implement some functions"
git checkout master
#rebase
git checkout new-feature
git checkout -b hotfix
git commit stuff
git checkout master
git merge hotfix
git branch -d hotfix
git checkout new-feature
git rebase master
git commit stuff
git checkout master
git merge new-feature
###### commits
#revert
git revert dd61ab32
git reset HEAD^ --hard
git push mathnet -f
#fix
git add stuff
git commit --amend
###### gitignore
#remove tracked files
git rm --cached -r some_files
#vim files
*~
*.swp
*.swo
#.gitignore itself
git config --global core.excludesfile .gitignore
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment