tips README

The project's README from github.com/git-tips/tips. As one markdown file: README.md.

git-tips

Collection of git-tips, want to add your tips? Checkout contributing.md

English | 中文 | Русский | 한국어 | Tiếng Việt | 日本語 | नेपाली | Polski | فارسی

Tools:

📖 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

git ls-tree --name-only -r <commit-ish>

Quickly switch to the previous branch

git checkout -

Alternatives:

git checkout @{-1}

Delete remote branch

git push origin --delete <remote_branchname>

Alternatives:

git push origin :<remote_branchname>
git branch -dr <remote/branch>

Delete remote tag

git push origin :refs/tags/<tag-name>

Undo local changes with the content in index(staging)

git checkout -- <file_name>

Alternatives:

git restore <file_name>

Reword the previous commit message

git commit -v --amend

See commit history for just the current branch

git cherry -v master

Amend author.

git commit --amend --author='Author Name <[email protected]>'

Stage parts of a changed file, instead of the entire file

git add -p

Pick commits across branches using cherry-pick

git checkout <branch-name> && git cherry-pick <commit-ish>

Grab a single file from a stash

git checkout <stash@{n}> -- <file_path>

Alternatives:

git checkout stash@{0} -- <file_path>

Create new working tree from a repository (git 2.5)

git worktree add -b <branch-name> <path> <start-point>

Create new working tree from HEAD state

git worktree add --detach <path> HEAD

Show all commits in the current branch yet to be merged to master

git cherry -v master

Alternatives:

git cherry -v master <branch-to-be-merged>

Modify previous commit without modifying the commit message

git add --all && git commit --amend --no-edit

Prunes references to remove branches that have been deleted in the remote.

git fetch -p

Alternatives:

git remote prune origin

Retrieve the commit hash of t

tips (git-tips/tips)

Searching Database…

21.7K ·GitHub
What is this?A community-maintained collection of the most commonly used git tips and tricks — short, ready-to-copy commands for everyday Git tasks, translated into eight other languages.
So it's a reference document, not a program I install?It's a reference, not a program: a README cheatsheet plus an interactive GitBook. A companion CLI called 'git-tip' lets you browse the tips from the terminal, but the repo itself is just the curated list.
How do I use it day to day?Open the README or GitBook, find your task in the Table of Contents, and copy the command you need. For a terminal workflow there's the 'git-tip' CLI, which the README shows running in a Docker container.
Will these commands work on any git version?The commands were tested on git 2.7.4, and the list includes newer idioms like 'switch' and 'restore' as modern alternatives — very old git installs may lack some features such as worktrees.
I'm new to git — where should I start?Start with 'Everyday Git in twenty commands or so' in the Miscellaneous section — a compact primer. Then work through Basic Operations before jumping into rebasing and history surgery.
How is the list organized?By task: Basic Operations, Branching, Log and History, Merging and Rebasing, Stashing, Remotes, Setup and Config, Submodules and Subtrees, Tagging, Undoing Changes, plus a Miscellaneous section.
Can I read it in another language?Yes — there are translations in Chinese, Russian, Korean, Vietnamese, Japanese, Nepali, Polish and Persian, linked at the top of the README.
What kind of problem can it bail me out of?Classics include removing sensitive data from history after you've already pushed, restoring a deleted file, grabbing a single file out of a stash, or automating a bisect with a test script to find the commit that broke something.
Is it still actively maintained?Yes — the README is generated from source files by a Node build script, and CI workflows rebuild it and deploy the GitBook docs automatically. That's also why GitHub lists JavaScript as the repo language: it's the build tooling, not the content.
Creator
git-tips
Size
1.3 MB
Stars
21.7K
Updated
CommitAug 10
Age
11y
Commits · 90 Days