2015-07-15 11:01:27 +00:00
|
|
|
[
|
2015-10-28 04:25:48 +00:00
|
|
|
{
|
|
|
|
"title": "Everyday Git in twenty commands or so",
|
|
|
|
"tip": "git help everyday"
|
|
|
|
},
|
2015-11-18 02:20:38 +00:00
|
|
|
{
|
|
|
|
"title": "Show helpful guides that come with Git",
|
|
|
|
"tip": "git help -g"
|
|
|
|
},
|
2015-07-15 11:01:27 +00:00
|
|
|
{
|
|
|
|
"title": "Overwrite pull",
|
|
|
|
"tip": "git fetch --all && git reset --hard origin/master"
|
|
|
|
},
|
2015-07-25 16:34:10 +00:00
|
|
|
{
|
|
|
|
"title": "List of all files till a commit",
|
2015-07-15 11:01:27 +00:00
|
|
|
"tip": "git ls-tree --name-only -r <commit-ish>"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"title": "Git reset first commit",
|
|
|
|
"tip": "git update-ref -d HEAD"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"title": "List all the conflicted files",
|
|
|
|
"tip": "git diff --name-only --diff-filter=U"
|
|
|
|
},
|
2015-07-28 16:38:59 +00:00
|
|
|
{
|
|
|
|
"title": "List of all files changed in a commit",
|
|
|
|
"tip": "git diff-tree --no-commit-id --name-only -r <commit-ish>"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"title":"Unstaged changes since last commit",
|
|
|
|
"tip":"git diff"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"title":"Changes staged for commit",
|
|
|
|
"tip":"git diff --cached"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"title":"Show both staged and unstaged changes",
|
|
|
|
"tip":"git diff HEAD"
|
|
|
|
},
|
2015-07-15 11:01:27 +00:00
|
|
|
{
|
|
|
|
"title": "List all branches that are already merged into master",
|
|
|
|
"tip": "git checkout master && git branch --merged"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"title": "Quickly switch to the previous branch",
|
|
|
|
"tip": "git checkout -"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"title": "Remove branches that have already been merged with master",
|
|
|
|
"tip": "git branch --merged | grep -v '\\*' | xargs -n 1 git branch -d"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"title": "List all branches and their upstreams, as well as last commit on branch",
|
|
|
|
"tip": "git branch -vv"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"title": "Track upstream branch",
|
|
|
|
"tip": "git branch -u origin/mybranch"
|
2015-07-15 14:30:26 +00:00
|
|
|
},
|
2015-07-15 13:14:33 +00:00
|
|
|
{
|
|
|
|
"title": "Delete local branch",
|
2015-07-16 03:37:15 +00:00
|
|
|
"tip": "git branch -d <local_branchname>"
|
2015-07-15 14:30:26 +00:00
|
|
|
},
|
2015-07-15 13:14:33 +00:00
|
|
|
{
|
|
|
|
"title": "Delete remote branch",
|
2015-07-28 19:04:09 +00:00
|
|
|
"tip": "git push origin --delete <remote_branchname>",
|
|
|
|
"alternatives": ["git push origin :<remote_branchname>"]
|
2015-07-15 17:26:22 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"title": "Undo local changes with the last content in head",
|
2015-07-16 03:37:15 +00:00
|
|
|
"tip": "git checkout -- <file_name>"
|
|
|
|
},
|
2015-07-31 10:43:57 +00:00
|
|
|
{
|
|
|
|
"title":"Revert: Undo a commit by creating a new commit",
|
|
|
|
"tip":"git revert <commit-ish>"
|
|
|
|
},
|
|
|
|
{
|
2015-08-07 00:57:15 +00:00
|
|
|
"title":"Reset: Discard commits, advised for private branch",
|
2015-07-31 10:43:57 +00:00
|
|
|
"tip":"git reset <commit-ish>"
|
|
|
|
},
|
2015-07-29 22:58:03 +00:00
|
|
|
{
|
|
|
|
"title": "Reword the previous commit message",
|
|
|
|
"tip": "git commit -v --amend"
|
|
|
|
},
|
2015-07-16 03:37:15 +00:00
|
|
|
{
|
|
|
|
"title": "Changing a remote's URL",
|
|
|
|
"tip": "git remote set-url origin <URL>"
|
2015-07-16 06:55:13 +00:00
|
|
|
},
|
2015-07-16 12:09:38 +00:00
|
|
|
{
|
|
|
|
"title": "Get list of all remote references",
|
2015-07-17 06:57:32 +00:00
|
|
|
"tip": "git remote",
|
2015-07-17 07:31:25 +00:00
|
|
|
"alternatives": ["git remote show"]
|
2015-07-16 12:09:38 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"title": "Get list of all local and remote branches",
|
|
|
|
"tip": "git branch -a"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"title": "Get only remote branches",
|
|
|
|
"tip": "git branch -r"
|
|
|
|
},
|
2015-07-16 06:55:13 +00:00
|
|
|
{
|
|
|
|
"title": "Stage parts of a changed file, instead of the entire file",
|
|
|
|
"tip": "git add -p"
|
2015-07-17 01:21:14 +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"
|
2015-07-22 07:56:24 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"title": "What changed since two weeks?",
|
|
|
|
"tip": "git whatchanged --since='2 weeks ago'"
|
2015-07-25 09:52:52 +00:00
|
|
|
},
|
2015-07-29 23:00:56 +00:00
|
|
|
{
|
|
|
|
"title": "See all commits made since forking from master",
|
|
|
|
"tip": "git log --no-merges --stat --reverse master.."
|
|
|
|
},
|
2015-07-25 09:52:52 +00:00
|
|
|
{
|
|
|
|
"title": "Pick commits across branches using cherry-pick",
|
|
|
|
"tip": "git checkout <branch-name> && cherry-pick <commit-ish>"
|
2015-07-25 17:37:41 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"title": "Find out branches containing commit-hash",
|
|
|
|
"tip": "git branch -a --contains <commit-ish>",
|
|
|
|
"alternatives": ["git branch --contains <commit-ish>"]
|
2015-07-27 04:03:30 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"title": "Git Aliases",
|
|
|
|
"tip": "git config --global alias.<handle> <command> \ngit config --global alias.st status"
|
2015-07-27 16:40:57 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"title":"Saving current state of tracked files without commiting",
|
2015-08-07 00:57:15 +00:00
|
|
|
"tip": "git stash",
|
|
|
|
"alternatives": ["git stash save"]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"title":"Saving current state including untracked files",
|
|
|
|
"tip": "git stash save -u",
|
|
|
|
"alternatives": ["git stash save --include-untracked"]
|
2015-07-27 16:40:57 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"title":"Show list of all saved stashes",
|
|
|
|
"tip": "git stash list"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"title": "Apply any stash without deleting from the stashed list",
|
|
|
|
"tip": "git stash apply <stash@{n}>"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"title":"Apply last stashed state and delete it from stashed list",
|
|
|
|
"tip": "git stash pop",
|
|
|
|
"alternatives": ["git stash apply stash@{0} && git stash drop stash@{0}"]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"title": "Delete all stored stashes",
|
|
|
|
"tip": "git stash clear",
|
|
|
|
"alternatives": ["git stash drop <stash@{n}>"]
|
2015-07-28 16:57:12 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"title":"Show all tracked files",
|
|
|
|
"tip":"git ls-files -t"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"title":"Show all untracked files",
|
|
|
|
"tip":"git ls-files --others"
|
2015-07-29 22:54:45 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"title": "Show all ignored files",
|
|
|
|
"tip": "git ls-files --others -i --exclude-standard"
|
2015-07-30 22:22:44 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"title": "Create new working tree from a repository (git 2.5)",
|
|
|
|
"tip":"git worktree add -b <branch-name> <path> <start-point>"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"title": "Create new working tree from HEAD state",
|
|
|
|
"tip": "git worktree add --detach <path> HEAD"
|
2015-08-11 06:11:10 +00:00
|
|
|
},
|
2015-08-11 06:17:49 +00:00
|
|
|
{
|
2015-08-11 06:18:14 +00:00
|
|
|
"title": "Before deleting untracked files/directory, do a dry run to get the list of these files/directories",
|
2015-08-11 06:17:49 +00:00
|
|
|
"tip": "git clean -n"
|
|
|
|
},
|
2015-08-11 06:11:10 +00:00
|
|
|
{
|
|
|
|
"title": "Forcefully remove untracked files",
|
|
|
|
"tip": "git clean -f"
|
|
|
|
},
|
|
|
|
{
|
2015-08-11 06:17:49 +00:00
|
|
|
"title": "Forcefully remove untracked directory",
|
2015-08-11 06:48:39 +00:00
|
|
|
"tip": "git clean -f -d",
|
2015-08-11 06:49:37 +00:00
|
|
|
"alternatives": ["git clean -df"]
|
2015-08-12 15:25:36 +00:00
|
|
|
},
|
|
|
|
{
|
2015-08-15 12:09:42 +00:00
|
|
|
"title": "Update all the submodules",
|
2015-08-12 15:25:36 +00:00
|
|
|
"tip": "git submodule foreach git pull"
|
2015-08-16 19:18:33 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"title": "Show all commits in the current branch yet to be merged to master",
|
|
|
|
"tip": "git cherry -v master",
|
|
|
|
"alternatives": ["git cherry -v master <branch-to-be-merged>"]
|
2015-08-19 09:29:29 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"title": "Rename a branch",
|
|
|
|
"tip": "git branch -m <new-branch-name>",
|
|
|
|
"alternatives": ["git branch -m [<old-branch-name>] <new-branch-name>"]
|
2015-08-21 14:04:59 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"title": "rebases 'feature' to 'master' and merges it in to master ",
|
|
|
|
"tip": "git checkout feature && git rebase @{-1} && git checkout @{-2} && git merge @{-1}"
|
2015-08-22 12:55:04 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"title": "Archive the `master` branch",
|
|
|
|
"tip": "git archive master --format=zip --output=master.zip"
|
2015-08-22 13:50:06 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"title": "Modify previous commit without modifying the commit message",
|
|
|
|
"tip": "git add --all && git commit --amend --no-edit"
|
2015-08-25 13:09:20 +00:00
|
|
|
},
|
|
|
|
{
|
2015-09-29 10:37:17 +00:00
|
|
|
"title": "Prunes branches that have been deleted in the remote.",
|
2015-08-25 13:09:20 +00:00
|
|
|
"tip": "git fetch -p",
|
|
|
|
"alternatives":["git remote prune origin"]
|
2015-08-28 12:47:40 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"title": "Retrieve the commit hash of the initial revision.",
|
|
|
|
"tip": " git rev-list --reverse HEAD | head -1"
|
2015-08-30 15:02:40 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"title": "Visualize the version tree.",
|
|
|
|
"tip": "git log --pretty=oneline --graph --decorate --all",
|
|
|
|
"alternatives":["gitk --all"]
|
2015-09-02 14:08:07 +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"
|
2015-09-02 14:28:41 +00:00
|
|
|
},
|
|
|
|
{
|
2015-09-02 14:51:18 +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"
|
2015-09-02 14:40:26 +00:00
|
|
|
},
|
|
|
|
{
|
2015-09-02 14:51:18 +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"
|
2015-09-13 15:52:57 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"title": "Export a branch with history to the a file.",
|
|
|
|
"tip": "git bundle create <file> <branch-name>"
|
2015-09-13 15:55:07 +00:00
|
|
|
},
|
|
|
|
{
|
2015-10-28 04:25:48 +00:00
|
|
|
"title": "Import from a bundle",
|
2015-09-13 15:55:07 +00:00
|
|
|
"tip": "git clone repo.bundle <repo-dir> -b <branch-name>"
|
2015-09-19 12:29:32 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"title": "Get the name of current branch.",
|
|
|
|
"tip": "git rev-parse --abbrev-ref HEAD"
|
2015-09-29 07:43: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"
|
2015-10-28 04:32:07 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"title": "Stash changes before rebasing",
|
|
|
|
"tip": "git rebase --autostash"
|
2015-10-28 10:54:02 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"title": "Fetch pull request by ID to a local branch",
|
|
|
|
"tip": "git fetch origin pull/<id>/head:<branch-name>",
|
|
|
|
"alternatives": ["git pull origin pull/<id>/head:<branch-name>"]
|
2015-11-03 03:00:16 +00:00
|
|
|
},
|
|
|
|
{
|
2015-12-18 15:26:55 +00:00
|
|
|
"title": "Show the most recent tag on the current branch.",
|
2015-11-03 03:00:16 +00:00
|
|
|
"tip": "git describe --tags --abbrev=0"
|
2015-12-18 15:26:55 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"title": "Show inline word diff.",
|
|
|
|
"tip": "git diff --word-diff"
|
2015-07-15 13:14:33 +00:00
|
|
|
}
|
2015-07-15 11:01:27 +00:00
|
|
|
]
|