Popular `git` terminal commands

Search committed files

Search for a pattern among all committed files in a repository.

Authored by: Jeet

Change URL of remote git repository

Sets the URL for a remote git repository to a new URL

Authored by: hobbs

Clone git repository with specific SSH Key and User

Clones a git repository given a specific SSH Key Path and configures it to use the desired Name and Email

Authored by: charlieVader

Clone all repos in a GitHub Organization

Uses the GitHub API to retrieve a list of repos (up to 100 per page) and clones them.

Authored by: Carlos Buenosvinos

Create new git remote branch

Creates a new local git branch and pushes the branch to a remote server to create a remote branch of the same name.

Authored by: Ikke

Delete local and remote git branch

Deletes a branch both locally and remotely. The first command deletes the remote branch, whereas the second command deletes the command locally.

Authored by: Matthew Rankin

Delete local git branch

Deletes a local git branch only if it has been fully merged into the upstream branch. To force delete the branch irrespective of the its merged status, add the `--force` flag.

Authored by: Matthew Rankin

Delete remote git branch

Deletes a remote git branch. A local git branch of the same name, if any, will remain untouched.

Authored by: Matthew Rankin

Modify the most recent commit message

Amends the most recent git commit with a new message. This will not update the commit on a remote branch unless you force push the branch,

Authored by: lfx_cool

Push a tag to a remote git repository

Pushes a single tag to a remote server

Authored by: Trevor

Rebase master into feature branch

Rebases master into the feature branch

Authored by: Varun Jindal

Remove a git submodule

Removes all traces of a git submodule from a repository. The `.git` dir of the submodule is kept around in the `/modules` folder of the main projects `.git` dir to make it possible to checkout past commits without requiring fetching from another repository.

Authored by: John Douthat

Remove all untracked files and folders

Remove all local untracked files and folders

Authored by: Robert Berger

Remove all local branches that aren't on the remote repository

Remove all local branches that doesn't exists in remote repository.

Authored by: Mailo Světel

Rename local git branch

Renames a local git branch while keeping the name of the upstream branch unchanged.

Authored by: siride

Reset file back to git revision

Resets a file back to a specific commit hash.

Authored by: Chris Lloyd

Reset local branch to match remote branch

Resets a local branch to match a remote branch by pulling the most recent changes from the remote branch and then force resetting the local branch to match the remote branch.

Authored by: Dan Moulding

Set upstream branch

Sets the upstream for a local branch to a remote branch.

Squash last n commits together

Squashes the last n commits together. This approach requires rewriting a commit message for the new squashed changes, unlike running `git rebase`.

Authored by: Chris Johnsen

Synchronize upstream branch

Sync the local branch to the remote branch with the same name.

Undo git add

Removes a file that was staged for commit by `git add`. Executing `git reset` without any file name will unstage all changes.

Authored by: genehack

Undo most recent git commit

Undos the last git commit while leaving the working tree (the state of the files on disk) untouched.

Authored by: Mark Amery

Delete newly git-ignored files from your repository

After adding new files to the .gitignore file, these commands will update the git index

Authored by: Matt Frear

Change username of git

Sets the username for git

Authored by: Orils