Skip to content

Git Tools

Jake Dube edited this page Oct 14, 2016 · 7 revisions

See the docs for more information

Miscellaneous

git commit

git add some_file.extension

  • Stages the file(s) to include in commit
  • This can be done on multiple files at once (or use the ".")

git blame -L line_start, line_end some_file.extension

  • Shows the last commit that made changes to the lines in the specified range.

Git Branch

git branch

  • Displays a list of local branches

git branch -d branch_name

  • Deletes a branch if it is fully merged

git branch -D branch_name

  • WARNING - Deletes a branch that is not fully merged!

git branch -v

  • Displays a list of branches with last commit message for each

git branch -vv

  • Displays a list of branches with last commit message and remote branch is tracking (if any) for each

git branch -u remote_name/branch_name

  • Sets the current branch to track to the remote branch "remote_name/branch_name"

git branch -a

  • Shows the complete list of branches (including those on the remotes)

Git Remote

git remote

  • Displays a list of configured remotes

git remote -v

  • Displays a list of configured remotes with the URL each is linked to

git remote add remote_name remote_URL

  • Matches a git remote with the name "remote_name" to the URL to act as a shortcut

git remote show remote_name

  • Shows helpful information about a remote

git remote rename old_name new_name

  • Renames a remote

git remote rm remote_name

  • Removes a remote

See this for setting up ssh