2016-06-07 18:34:22 +00:00
[ {
2016-03-29 16:11:53 +00:00
"title" : "Everyday Git in twenty commands or so" ,
"tip" : "git help everyday"
2016-06-07 18:34:22 +00:00
} , {
2016-03-29 16:11:53 +00:00
"title" : "Show helpful guides that come with Git" ,
"tip" : "git help -g"
2016-06-07 18:34:22 +00:00
} , {
2016-03-29 16:11:53 +00:00
"title" : "Overwrite pull" ,
"tip" : "git fetch --all && git reset --hard origin/master"
2016-06-07 18:34:22 +00:00
} , {
2016-03-29 16:11:53 +00:00
"title" : "List of all files till a commit" ,
"tip" : "git ls-tree --name-only -r <commit-ish>"
2016-06-07 18:34:22 +00:00
} , {
2016-03-29 16:11:53 +00:00
"title" : "Git reset first commit" ,
2016-08-29 05:24:26 +00:00
"tip" : "git update-ref -d HEAD"
2016-06-07 18:34:22 +00:00
} , {
2016-03-29 16:11:53 +00:00
"title" : "List all the conflicted files" ,
"tip" : "git diff --name-only --diff-filter=U"
2016-06-07 18:34:22 +00:00
} , {
2016-03-29 16:11:53 +00:00
"title" : "List of all files changed in a commit" ,
"tip" : "git diff-tree --no-commit-id --name-only -r <commit-ish>"
2016-06-07 18:34:22 +00:00
} , {
2016-03-29 16:11:53 +00:00
"title" : "Unstaged changes since last commit" ,
"tip" : "git diff"
2016-06-07 18:34:22 +00:00
} , {
2016-03-29 16:11:53 +00:00
"title" : "Changes staged for commit" ,
2016-06-12 14:41:16 +00:00
"tip" : "git diff --cached" ,
2016-06-13 11:47:46 +00:00
"alternatives" : [ "git diff --staged" ]
2016-06-07 18:34:22 +00:00
} , {
2016-03-29 16:11:53 +00:00
"title" : "Show both staged and unstaged changes" ,
"tip" : "git diff HEAD"
2016-06-07 18:34:22 +00:00
} , {
2016-03-29 16:11:53 +00:00
"title" : "List all branches that are already merged into master" ,
2016-06-07 07:30:05 +00:00
"tip" : "git branch --merged master"
2016-06-07 18:34:22 +00:00
} , {
2016-03-29 16:11:53 +00:00
"title" : "Quickly switch to the previous branch" ,
"tip" : "git checkout -"
2016-06-07 18:34:22 +00:00
} , {
2016-03-29 16:11:53 +00:00
"title" : "Remove branches that have already been merged with master" ,
2016-06-13 18:17:54 +00:00
"tip" : "git branch --merged master | grep -v '^\\*' | xargs -n 1 git branch -d" ,
"alternatives" : [ "git branch --merged master | grep -v '^\\*\\| master' | xargs -n 1 git branch -d # will not delete master if master is not checked out" ]
2016-06-07 18:34:22 +00:00
} , {
2016-03-29 16:11:53 +00:00
"title" : "List all branches and their upstreams, as well as last commit on branch" ,
"tip" : "git branch -vv"
2016-06-07 18:34:22 +00:00
} , {
2016-03-29 16:11:53 +00:00
"title" : "Track upstream branch" ,
"tip" : "git branch -u origin/mybranch"
2016-06-07 18:34:22 +00:00
} , {
2016-03-29 16:11:53 +00:00
"title" : "Delete local branch" ,
"tip" : "git branch -d <local_branchname>"
2016-06-07 18:34:22 +00:00
} , {
2016-03-29 16:11:53 +00:00
"title" : "Delete remote branch" ,
"tip" : "git push origin --delete <remote_branchname>" ,
2016-06-07 18:34:22 +00:00
"alternatives" : [ "git push origin :<remote_branchname>" ]
2016-06-17 10:56:27 +00:00
} , {
"title" : "Delete local tag" ,
"tip" : "git tag -d <tag-name>"
} , {
"title" : "Delete remote tag" ,
"tip" : "git push origin :refs/tags/<tag-name>"
2016-06-07 18:34:22 +00:00
} , {
2016-03-29 16:11:53 +00:00
"title" : "Undo local changes with the last content in head" ,
"tip" : "git checkout -- <file_name>"
2016-06-07 18:34:22 +00:00
} , {
2016-03-29 16:11:53 +00:00
"title" : "Revert: Undo a commit by creating a new commit" ,
"tip" : "git revert <commit-ish>"
2016-06-07 18:34:22 +00:00
} , {
2016-03-29 16:11:53 +00:00
"title" : "Reset: Discard commits, advised for private branch" ,
"tip" : "git reset <commit-ish>"
2016-06-07 18:34:22 +00:00
} , {
2016-03-29 16:11:53 +00:00
"title" : "Reword the previous commit message" ,
"tip" : "git commit -v --amend"
2016-06-13 16:36:12 +00:00
} , {
"title" : "See commit history for just the current branch" ,
"tip" : "git cherry -v master"
2016-06-07 18:34:22 +00:00
} , {
2016-03-29 16:11:53 +00:00
"title" : "Amend author." ,
"tip" : "git commit --amend --author='Author Name <email@address.com>'"
2016-06-07 18:34:22 +00:00
} , {
2016-03-29 16:11:53 +00:00
"title" : "Reset author, after author has been changed in the global config." ,
"tip" : "git commit --amend --reset-author --no-edit"
2016-06-07 18:34:22 +00:00
} , {
2016-03-29 16:11:53 +00:00
"title" : "Changing a remote's URL" ,
"tip" : "git remote set-url origin <URL>"
2016-06-07 18:34:22 +00:00
} , {
2016-03-29 16:11:53 +00:00
"title" : "Get list of all remote references" ,
"tip" : "git remote" ,
2016-06-07 18:34:22 +00:00
"alternatives" : [ "git remote show" ]
} , {
2016-03-29 16:11:53 +00:00
"title" : "Get list of all local and remote branches" ,
"tip" : "git branch -a"
2016-06-07 18:34:22 +00:00
} , {
2016-03-29 16:11:53 +00:00
"title" : "Get only remote branches" ,
"tip" : "git branch -r"
2016-06-07 18:34:22 +00:00
} , {
2016-03-29 16:11:53 +00:00
"title" : "Stage parts of a changed file, instead of the entire file" ,
"tip" : "git add -p"
2016-06-07 18:34:22 +00:00
} , {
2016-03-29 16:11:53 +00:00
"title" : "Get git bash completion" ,
"tip" : "curl http://git.io/vfhol > ~/.git-completion.bash && echo '[ -f ~/.git-completion.bash ] && . ~/.git-completion.bash' >> ~/.bashrc"
2016-06-07 18:34:22 +00:00
} , {
2016-03-29 16:11:53 +00:00
"title" : "What changed since two weeks?" ,
2016-06-07 07:42:13 +00:00
"tip" : "git log --no-merges --raw --since='2 weeks ago'" ,
"alternatives" : [ "git whatchanged --since='2 weeks ago'" ]
2016-06-07 18:34:22 +00:00
} , {
2016-03-29 16:11:53 +00:00
"title" : "See all commits made since forking from master" ,
"tip" : "git log --no-merges --stat --reverse master.."
2016-06-07 18:34:22 +00:00
} , {
2016-03-29 16:11:53 +00:00
"title" : "Pick commits across branches using cherry-pick" ,
2016-06-01 16:49:41 +00:00
"tip" : "git checkout <branch-name> && git cherry-pick <commit-ish>"
2016-06-07 18:34:22 +00:00
} , {
2016-03-29 16:11:53 +00:00
"title" : "Find out branches containing commit-hash" ,
"tip" : "git branch -a --contains <commit-ish>" ,
2016-06-07 18:34:22 +00:00
"alternatives" : [ "git branch --contains <commit-ish>" ]
} , {
2016-03-29 16:11:53 +00:00
"title" : "Git Aliases" ,
"tip" : "git config --global alias.<handle> <command> \ngit config --global alias.st status"
2016-06-07 18:34:22 +00:00
} , {
2016-03-29 16:11:53 +00:00
"title" : "Saving current state of tracked files without commiting" ,
"tip" : "git stash" ,
2016-06-07 18:34:22 +00:00
"alternatives" : [ "git stash save" ]
} , {
2016-03-29 16:11:53 +00:00
"title" : "Saving current state including untracked files" ,
"tip" : "git stash save -u" ,
2016-06-07 18:34:22 +00:00
"alternatives" : [ "git stash save --include-untracked" ]
} , {
2016-03-29 16:11:53 +00:00
"title" : "Show list of all saved stashes" ,
"tip" : "git stash list"
2016-06-07 18:34:22 +00:00
} , {
2016-03-29 16:11:53 +00:00
"title" : "Apply any stash without deleting from the stashed list" ,
"tip" : "git stash apply <stash@{n}>"
2016-06-07 18:34:22 +00:00
} , {
2016-03-29 16:11:53 +00:00
"title" : "Apply last stashed state and delete it from stashed list" ,
"tip" : "git stash pop" ,
2016-06-07 18:34:22 +00:00
"alternatives" : [ "git stash apply stash@{0} && git stash drop stash@{0}" ]
} , {
2016-03-29 16:11:53 +00:00
"title" : "Delete all stored stashes" ,
"tip" : "git stash clear" ,
2016-06-07 18:34:22 +00:00
"alternatives" : [ "git stash drop <stash@{n}>" ]
} , {
2016-03-29 16:11:53 +00:00
"title" : "Grab a single file from a stash" ,
"tip" : "git checkout <stash@{n}> -- <file_path>" ,
2016-06-07 18:34:22 +00:00
"alternatives" : [ "git checkout stash@{0} -- <file_path>" ]
} , {
2016-03-29 16:11:53 +00:00
"title" : "Show all tracked files" ,
"tip" : "git ls-files -t"
2016-06-07 18:34:22 +00:00
} , {
2016-03-29 16:11:53 +00:00
"title" : "Show all untracked files" ,
"tip" : "git ls-files --others"
2016-06-07 18:34:22 +00:00
} , {
2016-03-29 16:11:53 +00:00
"title" : "Show all ignored files" ,
"tip" : "git ls-files --others -i --exclude-standard"
2016-06-07 18:34:22 +00:00
} , {
2016-03-29 16:11:53 +00:00
"title" : "Create new working tree from a repository (git 2.5)" ,
"tip" : "git worktree add -b <branch-name> <path> <start-point>"
2016-06-07 18:34:22 +00:00
} , {
2016-03-29 16:11:53 +00:00
"title" : "Create new working tree from HEAD state" ,
"tip" : "git worktree add --detach <path> HEAD"
2016-06-07 18:34:22 +00:00
} , {
2016-03-29 16:11:53 +00:00
"title" : "Untrack files without deleting" ,
"tip" : "git rm --cached <file_path>" ,
2016-06-07 18:34:22 +00:00
"alternatives" : [ "git rm --cached -r <directory_path>" ]
} , {
2016-03-29 16:11:53 +00:00
"title" : "Before deleting untracked files/directory, do a dry run to get the list of these files/directories" ,
"tip" : "git clean -n"
2016-06-07 18:34:22 +00:00
} , {
2016-03-29 16:11:53 +00:00
"title" : "Forcefully remove untracked files" ,
"tip" : "git clean -f"
2016-06-07 18:34:22 +00:00
} , {
2016-03-29 16:11:53 +00:00
"title" : "Forcefully remove untracked directory" ,
"tip" : "git clean -f -d" ,
2016-06-07 18:34:22 +00:00
"alternatives" : [ "git clean -df" ]
} , {
2016-03-29 16:11:53 +00:00
"title" : "Update all the submodules" ,
2016-06-18 09:42:31 +00:00
"tip" : "git submodule foreach git pull" ,
2016-06-18 09:43:34 +00:00
"alternatives" : [ "git submodule update --init --recursive" , "git submodule update --remote" ]
2016-06-07 18:34:22 +00:00
} , {
2016-03-29 16:11:53 +00:00
"title" : "Show all commits in the current branch yet to be merged to master" ,
"tip" : "git cherry -v master" ,
2016-06-07 18:34:22 +00:00
"alternatives" : [ "git cherry -v master <branch-to-be-merged>" ]
} , {
2016-03-29 16:11:53 +00:00
"title" : "Rename a branch" ,
"tip" : "git branch -m <new-branch-name>" ,
2016-06-07 18:34:22 +00:00
"alternatives" : [ "git branch -m [<old-branch-name>] <new-branch-name>" ]
} , {
2016-07-31 12:52:27 +00:00
"title" : "Rebases 'feature' to 'master' and merges it in to master " ,
2016-08-15 18:13:07 +00:00
"tip" : "git rebase master feature && git checkout master && git merge -"
2016-06-07 18:34:22 +00:00
} , {
2016-03-29 16:11:53 +00:00
"title" : "Archive the `master` branch" ,
"tip" : "git archive master --format=zip --output=master.zip"
2016-06-07 18:34:22 +00:00
} , {
2016-03-29 16:11:53 +00:00
"title" : "Modify previous commit without modifying the commit message" ,
"tip" : "git add --all && git commit --amend --no-edit"
2016-06-07 18:34:22 +00:00
} , {
2016-06-02 11:14:25 +00:00
"title" : "Prunes references to remote branches that have been deleted in the remote." ,
2016-03-29 16:11:53 +00:00
"tip" : "git fetch -p" ,
2016-06-07 18:34:22 +00:00
"alternatives" : [ "git remote prune origin" ]
} , {
2016-03-29 16:11:53 +00:00
"title" : "Retrieve the commit hash of the initial revision." ,
2016-06-29 16:40:25 +00:00
"tip" : " git rev-list --reverse HEAD | head -1" ,
2016-06-30 18:00:27 +00:00
"alternatives" : [ "git rev-list --max-parents=0 HEAD" , "git log --pretty=oneline | tail -1 | cut -c 1-40" , "git log --pretty=oneline --reverse | head -1 | cut -c 1-40" ]
2016-06-07 18:34:22 +00:00
} , {
2016-03-29 16:11:53 +00:00
"title" : "Visualize the version tree." ,
"tip" : "git log --pretty=oneline --graph --decorate --all" ,
2016-06-07 18:34:22 +00:00
"alternatives" : [ "gitk --all" ]
} , {
2016-03-29 16:11:53 +00:00
"title" : "Deploying git tracked subfolder to gh-pages" ,
"tip" : "git subtree push --prefix subfolder_name origin gh-pages" ,
"alternatives" : "git subtree push --prefix subfolder_name origin branch_name"
2016-06-07 18:34:22 +00:00
} , {
2016-03-29 16:11:53 +00:00
"title" : "Adding a project to repo using subtree" ,
"tip" : "git subtree add --prefix=<directory_name>/<project_name> --squash git@github.com:<username>/<project_name>.git master"
2016-06-07 18:34:22 +00:00
} , {
2016-03-29 16:11:53 +00:00
"title" : "Get latest changes in your repo for a linked project using subtree" ,
"tip" : "git subtree pull --prefix=<directory_name>/<project_name> --squash git@github.com:<username>/<project_name>.git master"
2016-06-07 18:34:22 +00:00
} , {
2016-06-05 18:23:49 +00:00
"title" : "Export a branch with history to a file." ,
2016-03-29 16:11:53 +00:00
"tip" : "git bundle create <file> <branch-name>"
2016-06-07 18:34:22 +00:00
} , {
2016-03-29 16:11:53 +00:00
"title" : "Import from a bundle" ,
"tip" : "git clone repo.bundle <repo-dir> -b <branch-name>"
2016-06-07 18:34:22 +00:00
} , {
2016-03-29 16:11:53 +00:00
"title" : "Get the name of current branch." ,
"tip" : "git rev-parse --abbrev-ref HEAD"
2016-06-07 18:34:22 +00:00
} , {
2016-03-29 16:11:53 +00:00
"title" : "Ignore one file on commit (e.g. Changelog)." ,
"tip" : "git update-index --assume-unchanged Changelog; git commit -a; git update-index --no-assume-unchanged Changelog"
2016-06-07 18:34:22 +00:00
} , {
2016-03-29 16:11:53 +00:00
"title" : "Stash changes before rebasing" ,
"tip" : "git rebase --autostash"
2016-06-07 18:34:22 +00:00
} , {
2016-03-29 16:11:53 +00:00
"title" : "Fetch pull request by ID to a local branch" ,
"tip" : "git fetch origin pull/<id>/head:<branch-name>" ,
2016-06-07 18:34:22 +00:00
"alternatives" : [ "git pull origin pull/<id>/head:<branch-name>" ]
} , {
2016-03-29 16:11:53 +00:00
"title" : "Show the most recent tag on the current branch." ,
"tip" : "git describe --tags --abbrev=0"
2016-06-07 18:34:22 +00:00
} , {
2016-03-29 16:11:53 +00:00
"title" : "Show inline word diff." ,
"tip" : "git diff --word-diff"
2016-07-07 13:42:54 +00:00
} , {
"title" : "Show changes using common diff tools." ,
"tip" : "git difftool -t <commit1> <commit2> <path>"
2016-06-07 18:34:22 +00:00
} , {
2016-03-29 16:11:53 +00:00
"title" : "Don’ t consider changes for tracked file." ,
"tip" : "git update-index --assume-unchanged <file_name>"
2016-06-07 18:34:22 +00:00
} , {
2016-03-29 16:11:53 +00:00
"title" : "Undo assume-unchanged." ,
"tip" : "git update-index --no-assume-unchanged <file_name>"
2016-06-07 18:34:22 +00:00
} , {
2016-03-29 16:11:53 +00:00
"title" : "Clean the files from `.gitignore`." ,
"tip" : "git clean -X -f"
2016-06-07 18:34:22 +00:00
} , {
2016-03-29 16:11:53 +00:00
"title" : "Restore deleted file." ,
"tip" : "git checkout <deleting_commit>^ -- <file_path>"
2016-06-07 18:34:22 +00:00
} , {
2016-03-29 16:11:53 +00:00
"title" : "Restore file to a specific commit-hash" ,
"tip" : "git checkout <commit-ish> -- <file_path>"
2016-06-07 18:34:22 +00:00
} , {
2016-03-29 16:11:53 +00:00
"title" : "Always rebase instead of merge on pull." ,
2016-10-05 10:18:35 +00:00
"tip" : "git config --global pull.rebase true" ,
"alternatives" : [ "#git < 1.7.9\ngit config --global branch.autosetuprebase always" ]
2016-06-07 18:34:22 +00:00
} , {
2016-03-29 16:11:53 +00:00
"title" : "List all the alias and configs." ,
"tip" : "git config --list"
2016-06-07 18:34:22 +00:00
} , {
2016-03-29 16:11:53 +00:00
"title" : "Make git case sensitive." ,
"tip" : "git config --global core.ignorecase false"
2016-06-16 08:46:41 +00:00
} , {
"title" : "Add custom editors." ,
"tip" : "git config --global core.editor '$EDITOR'"
2016-06-07 18:34:22 +00:00
} , {
2016-03-29 16:11:53 +00:00
"title" : "Auto correct typos." ,
"tip" : "git config --global help.autocorrect 1"
2016-06-07 18:34:22 +00:00
} , {
2016-03-29 16:11:53 +00:00
"title" : "Check if the change was a part of a release." ,
"tip" : "git name-rev --name-only <SHA-1>"
2016-06-07 18:34:22 +00:00
} , {
2016-03-29 16:11:53 +00:00
"title" : "Dry run. (any command that supports dry-run flag should do.)" ,
"tip" : "git clean -fd --dry-run"
2016-06-07 18:34:22 +00:00
} , {
2016-03-29 16:11:53 +00:00
"title" : "Marks your commit as a fix of a previous commit." ,
"tip" : "git commit --fixup <SHA-1>"
2016-06-07 18:34:22 +00:00
} , {
2016-07-31 12:52:27 +00:00
"title" : "Squash fixup commits normal commits." ,
2016-03-29 16:11:53 +00:00
"tip" : "git rebase -i --autosquash"
2016-06-07 18:34:22 +00:00
} , {
2016-07-31 12:52:27 +00:00
"title" : "Skip staging area during commit." ,
2016-06-22 21:20:34 +00:00
"tip" : "git commit --only <file_path>"
2016-06-22 09:55:18 +00:00
} , {
"title" : "Interactive staging." ,
"tip" : "git add -i"
2016-06-07 18:34:22 +00:00
} , {
2016-03-29 16:11:53 +00:00
"title" : "List ignored files." ,
"tip" : "git check-ignore *"
2016-06-07 18:34:22 +00:00
} , {
2016-03-29 16:11:53 +00:00
"title" : "Status of ignored files." ,
"tip" : "git status --ignored"
2016-06-07 18:34:22 +00:00
} , {
2016-03-29 16:11:53 +00:00
"title" : "Commits in Branch1 that are not in Branch2" ,
"tip" : "git log Branch1 ^Branch2"
2016-06-07 18:34:22 +00:00
} , {
2016-07-31 12:52:27 +00:00
"title" : "Reuse recorded resolution, record and reuse previous conflicts resolutions." ,
2016-06-08 20:54:04 +00:00
"tip" : "git config --global rerere.enabled 1"
2016-06-07 18:34:22 +00:00
} , {
2016-03-29 16:11:53 +00:00
"title" : "Open all conflicted files in an editor." ,
"tip" : "git diff --name-only | uniq | xargs $EDITOR"
2016-06-07 18:34:22 +00:00
} , {
2016-03-29 16:11:53 +00:00
"title" : "Count unpacked number of objects and their disk consumption." ,
"tip" : "git count-objects --human-readable"
2016-06-07 18:34:22 +00:00
} , {
2016-06-08 20:00:17 +00:00
"title" : "Prune all unreachable objects from the object database." ,
"tip" : "git gc --prune=now --aggressive"
} , {
"title" : "Instantly browse your working repository in gitweb." ,
"tip" : "git instaweb [--local] [--httpd=<httpd>] [--port=<port>] [--browser=<browser>]"
} , {
"title" : "View the GPG signatures in the commit log" ,
"tip" : "git log --show-signature"
2016-06-07 18:34:22 +00:00
} , {
2016-04-06 20:20:46 +00:00
"title" : "Remove entry in the global config." ,
"tip" : "git config --global --unset <entry-name>"
2016-06-08 20:00:17 +00:00
} , {
2016-04-10 15:37:36 +00:00
"title" : "Checkout a new branch without any history" ,
"tip" : "git checkout --orphan <branch_name>"
2016-06-08 20:00:17 +00:00
} , {
"title" : "Extract file from another branch." ,
"tip" : "git show <branch_name>:<file_name>"
} , {
"title" : "List only the root and merge commits." ,
"tip" : "git log --first-parent"
} , {
2016-06-28 09:27:19 +00:00
"title" : "Change previous two commits with an interactive rebase." ,
2016-06-08 20:00:17 +00:00
"tip" : "git rebase --interactive HEAD~2"
} , {
"title" : "List all branch is WIP" ,
"tip" : "git checkout master && git branch --no-merged"
} , {
"title" : "Find guilty with binary search" ,
"tip" : "git bisect start # Search start \ngit bisect bad # Set point to bad commit \ngit bisect good v2.6.13-rc2 # Set point to good commit|tag \ngit bisect bad # Say current state is bad \ngit bisect good # Say current state is good \ngit bisect reset # Finish search \n"
} , {
2016-06-07 05:21:11 +00:00
"title" : "Bypass pre-commit and commit-msg githooks" ,
"tip" : "git commit --no-verify"
2016-06-08 20:54:04 +00:00
} , {
"title" : "List commits and changes to a specific file (even through renaming)" ,
"tip" : "git log --follow -p -- <file_path>"
2016-06-10 10:40:16 +00:00
} , {
"title" : "Clone a single branch" ,
"tip" : "git clone -b <branch-name> --single-branch https://github.com/user/repo.git"
2016-06-12 08:10:42 +00:00
} , {
"title" : "Create and switch new branch" ,
2016-06-13 17:30:07 +00:00
"tip" : "git checkout -b <branch-name>" ,
"alternatives" : [ "git branch <branch-name> && git checkout <branch-name>" ]
2016-06-11 17:59:23 +00:00
} , {
"title" : "Ignore file mode changes on commits" ,
"tip" : "git config core.fileMode false"
2016-06-13 14:00:11 +00:00
} , {
"title" : "Turn off git colored terminal output" ,
"tip" : "git config --global color.ui false"
} , {
2016-07-31 12:52:27 +00:00
"title" : "Specific color settings" ,
2016-06-13 14:00:11 +00:00
"tip" : "git config --global <specific command e.g branch, diff> <true, false or always>"
2016-06-16 09:49:33 +00:00
} , {
"title" : "Show all local branches ordered by recent commits" ,
"tip" : "git for-each-ref --sort=-committerdate --format='%(refname:short)' refs/heads/"
2016-06-16 23:58:38 +00:00
} , {
"title" : "Find lines matching the pattern (regex or string) in tracked files" ,
"tip" : "git grep --heading --line-number 'foo bar'"
2016-06-17 15:31:08 +00:00
} , {
"title" : "Clone a shallow copy of a repository" ,
"tip" : "git clone https://github.com/user/repo.git --depth 1"
2016-06-18 14:28:58 +00:00
} , {
"title" : "Search Commit log across all branches for given text" ,
"tip" : "git log --all --grep='<given-text>'"
2016-06-19 17:50:21 +00:00
} , {
"title" : "Get first commit in a branch (from master)" ,
"tip" : "git log master..<branch-name> --oneline | tail -1"
2016-06-23 17:13:26 +00:00
} , {
2016-07-03 13:51:33 +00:00
"title" : "Unstaging Staged file" ,
2016-06-23 17:13:26 +00:00
"tip" : "git reset HEAD <file-name>"
2016-06-25 05:46:58 +00:00
} , {
"title" : "Force push to Remote Repository" ,
"tip" : "git push -f <remote-name> <branch-name>"
2016-06-25 06:02:14 +00:00
} , {
"title" : "Adding Remote name" ,
2016-06-29 15:14:46 +00:00
"tip" : "git remote add <remote-nickname> <remote-url>"
2016-07-03 13:51:33 +00:00
} , {
"title" : "Show the author, time and last revision made to each line of a given file" ,
"tip" : "git blame <file-name>"
2016-07-16 08:03:32 +00:00
} , {
"title" : "Group commits by authors and title" ,
"tip" : "git shortlog"
2016-08-10 18:08:56 +00:00
} , {
"title" : "Forced push but still ensure you don't overwrite other's work" ,
"tip" : "git push --force-with-lease <remote-name> <branch-name>"
2016-08-12 11:04:12 +00:00
} , {
"title" : "Show how many lines does an author contribute" ,
"tip" : "git log --author='_Your_Name_Here_' --pretty=tformat: --numstat | gawk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf \"added lines: %s removed lines: %s total lines: %s\n\", add, subs, loc }' -" ,
"alternatives" : [ "git log --author='_Your_Name_Here_' --pretty=tformat: --numstat | awk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf \"added lines: %s, removed lines: %s, total lines: %s\n\", add, subs, loc }' - # on Mac OSX" ]
2016-08-14 18:14:08 +00:00
} , {
"title" : "Revert: Reverting an entire merge" ,
"tip" : "git revert -m 1 <commit-ish>"
2016-08-14 15:06:13 +00:00
} , {
"title" : "Number of commits in a branch" ,
"tip" : "git rev-list --count <branch-name>"
2016-08-26 11:41:30 +00:00
} , {
"title" : "Alias: git undo" ,
"tip" : "git config --global alias.undo '!f() { git reset --hard $(git rev-parse --abbrev-ref HEAD)@{${1-1}}; }; f'"
2016-09-24 17:40:03 +00:00
} , {
"title" : "Add object notes" ,
"tip" : "git notes add -m 'Note on the previous commit....'"
2016-09-24 17:41:34 +00:00
} , {
"title" : "Show all the git-notes" ,
"tip" : "git log --show-notes='*'"
2016-09-28 16:13:13 +00:00
} , {
"title" : "Apply commit from another repository" ,
"tip" : "git --git-dir=<source-dir>/.git format-patch -k -1 --stdout <SHA1> | git am -3 -k"
2016-10-02 03:22:29 +00:00
} , {
"title" : "Specific fetch reference" ,
"tip" : "git fetch origin master:refs/remotes/origin/mymaster"
2016-09-28 16:37:48 +00:00
} , {
"title" : "Find common ancestor of two branches" ,
"tip" : "diff -u <(git rev-list --first-parent BranchA) <(git rev-list --first-parent BranchB) | sed -ne 's/^ //p' | head -1"
2016-10-09 18:14:08 +00:00
} , {
"title" : "List unpushed git commits" ,
"tip" : "git log --branches --not --remotes" ,
"alternatives" : [ "git log @{u}.." , "git cherry -v" ]
2016-10-24 16:10:06 +00:00
} , {
"title" : "Add everything, but whitespace changes" ,
"tip" : "git diff --ignore-all-space | git apply --cached"
2016-10-30 14:41:20 +00:00
} , {
"title" : "Edit [local/global] git config" ,
"tip" : "git config [--global] --edit"
2016-10-31 15:48:46 +00:00
} , {
"title" : "blame on certain range" ,
"tip" : "git blame -L <start>,<end>"
2016-12-12 14:46:32 +00:00
} , {
"title" : "Show a Git logical variable." ,
"tip" : "git var -l | <variable>"
2016-12-25 15:53:02 +00:00
} , {
"title" : "Preformatted patch file." ,
"tip" : "git format-patch -M upstream..topic"
2016-10-24 16:10:06 +00:00
} ]