Tips
Most commonly used git tips and tricks.
Install / Use
/learn @git-tips/TipsREADME
git-tips
Collection of
git-tips, want to add your tips? Checkout contributing.md
English | 中文 | Русский | 한국어 | Tiếng Việt | 日本語 | नेपाली | Polski | فارسی
Tools:
- git-tip - A handy CLI to make optimum use of these tips. (Here in Docker container)
📖 Read the interactive GitBook documentation here!
P.S: All these commands are tested on git version 2.7.4 (Apple Git-66).
Table of Contents
- Basic Operations
- List of all files till a commit
- Quickly switch to the previous branch
- Delete remote branch
- Delete remote tag
- Undo local changes with the content in index(staging)
- Reword the previous commit message
- See commit history for just the current branch
- Amend author.
- Stage parts of a changed file, instead of the entire file
- Pick commits across branches using cherry-pick
- Grab a single file from a stash
- Create new working tree from a repository (git 2.5)
- Create new working tree from HEAD state
- Show all commits in the current branch yet to be merged to master
- Modify previous commit without modifying the commit message
- Prunes references to remove branches that have been deleted in the remote.
- Retrieve the commit hash of the initial revision.
- Import from a bundle
- Ignore one file on commit (e.g. Changelog).
- Fetch pull request by ID to a local branch
- Restore deleted file.
- Restore file to a specific commit-hash
- Marks your commit as a fix of a previous commit.
- Skip staging area during commit.
- Interactive staging.
- Status of ignored files.
- Checkout a new branch without any history
- Find guilty with binary search
- Bypass pre-commit and commit-msg githooks
- Clone a single branch
- Create and switch new branch
- Show all local branches ordered by recent commits
- Clone a shallow copy of a repository
- Force push to Remote Repository
- Group commits by authors and title
- Forced push but still ensure you don't overwrite other's work
- Number of commits in a branch
- Add object notes
- Apply commit from another repository
- Specific fetch reference
- Generates a summary of pending changes
- Show git status short
- Checkout a commit prior to a day ago
- Push the current branch to the same name on the remote repository
- Push a new local branch to remote repository and track
- Update a submodule to the latest commit
- Duplicating a repository
- Branching
- List all branches that are already merged into master
- Remove branches that have already been merged with master
- List all branches and their upstreams, as well as last commit on branch
- Track upstream branch
- Delete local branch
- Get list of all local and remote branches
- Get only remote branches
- Find out branches containing commit-hash
- Rename a branch
- Archive the
masterbranch - Delete local branches that has been squash and merged in the remote.
- Export a branch with history to a file.
- Get the name of current branch.
- Show the most recent tag on the current branch.
- List all branch is WIP
- Preformatted patch file.
- Switch to a branch (modern alternative to checkout)
- Log and History
- Show helpful guides that come with Git
- Search change by content
- Show changes over time for specific file
- List all the conflicted files
- List of all files changed in a commit
- Unstaged changes since last commit
- Changes staged for commit
- Show both staged and unstaged changes
- What changed since two weeks?
- See all commits made since forking from master
- Show all tracked files
- Show all untracked files
- Show all ignored files
- Visualize the version tree.
- Visualize the tree including commits that are only referenced from reflogs
- Show inline word diff.
- Show changes using common diff tools.
- Commits in Branch1 that are not in Branch2
- List n last commits
- Open all conflicted files in an editor.
- View the GPG signatures in the commit log
- Extract file from another branch.
- List only the root and merge commits.
- List commits and changes to a specific file (even through renaming)
- Search Commit log across all branches for given text
- Get first commit in a branch (from master)
- Show the author, time and last revision made to each line of a given file
- Show how many lines does an author contribute
- Show all the git-notes
- List unpushed git commits
- Add everything, but whitespace changes
- blame on certain range
- Show a Git logical variable.
- Get the repo name.
- logs between date range
- Exclude author from logs
- View expanded details of changes in last commit
- Visualize each position of HEAD in the last 30 days
- Merging and Rebasing
