Popular `git` terminal commands

Find all files in a directory that don't contain a string

Finds all files in a repository that don't contain a given pattern.

Authored by: ghostdog74

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

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

Ammends 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

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

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

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

Squash last n commits together

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

Authored by: Chris Johnsen

Undo git add

Removes a file that was staged for commit by `git add`. Executing `git reset` withou 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