Helpful Git commands

git_logo

Here is a list of helpful HOWTO Git commands. Please follow/star this github repository for updates.

Everyday Git in twenty commands or so

Show helpful guides that come with Git

Overwrite pull

List of all files till a commit

Git reset first commit

List all the conflicted files

List of all files changed in a commit

Unstaged changes since last commit

Changes staged for commit

Alternatives:

Show both staged and unstaged changes

List all branches that are already merged into master

Quickly switch to the previous branch

Remove branches that have already been merged with master

Alternatives:

List all branches and their upstreams, as well as last commit on branch

Track upstream branch

Delete local branch

Delete remote branch

Alternatives:

Undo local changes with the last content in head

Revert: Undo a commit by creating a new commit

Reset: Discard commits, advised for private branch

Reword the previous commit message

See commit history for just the current branch

Amend author.

Reset author, after author has been changed in the global config.

Changing a remote’s URL

Get list of all remote references

Alternatives:

Get list of all local and remote branches

Get only remote branches

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

Get git bash completion

What changed since two weeks?

Alternatives:

See all commits made since forking from master

Pick commits across branches using cherry-pick

Find out branches containing commit-hash

Alternatives:

Git Aliases

Saving current state of tracked files without commiting

Alternatives:

Saving current state including untracked files

Alternatives:

Show list of all saved stashes

Apply any stash without deleting from the stashed list

Apply last stashed state and delete it from stashed list

Alternatives:

Delete all stored stashes

Alternatives:

Grab a single file from a stash

Alternatives:

Show all tracked files

Show all untracked files

Show all ignored files

Create new working tree from a repository (git 2.5)

Create new working tree from HEAD state

Untrack files without deleting

Alternatives:

Before deleting untracked files/directory, do a dry run to get the list of these files/directories

Forcefully remove untracked files

Forcefully remove untracked directory

Alternatives:

Update all the submodules

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

Alternatives:

Rename a branch

Alternatives:

rebases ‘feature’ to ‘master’ and merges it in to master

Archive the master branch

Modify previous commit without modifying the commit message

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

Alternatives:

Retrieve the commit hash of the initial revision.

Visualize the version tree.

Alternatives:

Deploying git tracked subfolder to gh-pages

Adding a project to repo using subtree

Get latest changes in your repo for a linked project using subtree

Export a branch with history to a file.

Import from a bundle

Get the name of current branch.

Ignore one file on commit (e.g. Changelog).

Stash changes before rebasing

Fetch pull request by ID to a local branch

Alternatives:

Show the most recent tag on the current branch.

Show inline word diff.

Don’t consider changes for tracked file.

Undo assume-unchanged.

Clean the files from .gitignore.

Restore deleted file.

Restore file to a specific commit-hash

Always rebase instead of merge on pull.

List all the alias and configs.

Make git case sensitive.

Auto correct typos.

Check if the change was a part of a release.

Dry run. (any command that supports dry-run flag should do.)

Marks your commit as a fix of a previous commit.

squash fixup commits normal commits.

skip staging area during commit.

List ignored files.

Status of ignored files.

Commits in Branch1 that are not in Branch2

reuse recorded resolution, record and reuse previous conflicts resolutions.

Open all conflicted files in an editor.

Count unpacked number of objects and their disk consumption.

Prune all unreachable objects from the object database.

Instantly browse your working repository in gitweb.

View the GPG signatures in the commit log

Remove entry in the global config.

Checkout a new branch without any history

Extract file from another branch.

List only the root and merge commits.

Merge previous two commits into one.

List all branch is WIP

Find guilty with binary search

Bypass pre-commit and commit-msg githooks

List commits and changes to a specific file (even through renaming)

Clone a single branch

Create and switch new branch

Alternatives:

Ignore file mode changes on commits

Turn off git colored terminal output

specific color settings