This cheat sheet contains commands for using git
git tag |
List all available tags in Git
|
git tag -l [tag_number] |
search for tags with the particular tag_number
|
git tag -a [tag_number] -m [message] |
creates an annotated tag with an optional tagging message
|
git show [tag_number] |
shows the tagger information
|
git tag [tag_number]-lw |
creates a lightweight tag
|
git tag -a [tag_number] [part_of_check_sum] |
tags the commit after you've moved passed them
|
git push origin [tag_number] |
push version_number to shared server after you have created them.
|
git push origin --tags |
push tags to shared server
|
git checkout -b [branch_name] [tag_name] |
put a version of the repository in your working directory that looks like a specific tag
|
git init |
Initializes a new git repository in the current directory
|
git clone url |
Clone an existing Git repository located at in the current directory
|
git clone url directory_name |
Clone an existing Git repository located at in directory_name
|
git status |
used to determine which files are in which state
|
git status -s |
the short and compact representation of git status
|
git rm "file_name" |
Removes the file from your tracked files and the working directory
|
git rm --cached "file_name" |
Removes the files from your tracked files but keeps the file in the working directory
|
git mv "file_from" "file_to" |
Renames the file form "file_from" to "file_to"
|
git reset [file_name] |
used to unstage the "file_name
|
git checkout -- [file_name] |
reverts a file to the previous version
|
git add file_name |
Stage file_name for commit
|
git add -A |
Stage all modified or new files for commit
|
git reset file_name |
Unstage file_name
|
git remote add "name" "url" |
Create a new remote named "name" for the repository at "url"
|
git fetch "remote" |
Download all changes from "remote", but don't integrate into current branch
|
git merge "remote"/"branch" |
Merge "remote]/[branch" into current branch
|
git push "remote" "branch" |
Push local changes in "branch" to "remote"/"branch"
|
git pull "remote" "branch" |
Fetch and merge all changes from "remote"/"branch" into current branch
|
git commit -m "message" |
Commit staged changes with "message" describing changes
|
git commit --amend |
Edit the previous commit message or contents
|
git commit -a -m "message" |
Stages all already tracked files and commits them
|
git remote add "name" "url" |
Create a new remote named "name" for the repository at "url"
|
git branch "name" |
Create a new branch named "name"
|
git checkout "name" |
Switch to branch named "name"
|
git merge "branch" |
Merge "branch" into current branch
|
git merge --no-ff "branch" |
Merge "branch" into current branch, keeping branch history
|
git log |
View the commit history of the current branch
|
git log "branch" |
View the commit history of "branch"
|
git log --stat |
Prints below each commit entry a list of modified files, how many files where changed, and how many lines in those files where added or removed
|
git log --pretty=online |
This option changes the log output to formats other than the default
|
git log --graph |
Display an ASCII graph of the branch and merge history beside the log output
|
git diff |
View unstaged changes between the current state of the code and the last commit
|
git diff --cached |
View staged changes between last commit and the current state of the code
|
git diff "branch1" "branch2" |
View differences between "branch1" and "branch2"
|
No comments yet.
Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.