0% found this document useful (0 votes)
51 views2 pages

Git Cheat Sheet

Uploaded by

Hưng Duy Dao
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
51 views2 pages

Git Cheat Sheet

Uploaded by

Hưng Duy Dao
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

GIT

CHEAT SHEET

Manage local changes

Show all commits.


git log
Top 10 commands
Show the state of the working AND staging
areas. Show changed files.
Create a new repository.
git status
git init
List the changes between your current
Add all current changes to the next commit. working directory AND staging area.
git add . git diff
Commit all local changes in tracked files Show a log of all the updates made to a
git commit -a -m ‘message’ branch.
git reflog
Create a new branch.
git branch <new-branch>

Switch the current branch.


git checkout <branch> Manage a branch
Update the local branch (HEAD branch).
git pull <remote> <branch> List all the branches.
git branch -av
Publish local changes to the remote.
git push <remote> <branch> Create a new branch.
git branch <new-branch>
Merge a branch into the current branch.
git merge <branch> Delete a local branch.
git branch -d <branch>
Clone a GIT repository.
git clone ssh://[email protected]/repo.git Delete a remote branch.
git push <remote> --delete <branch>
Reset the current HEAD to a specific commit.
git reset --hard <commit>

https://timmousk.com/.
GIT CHEAT SHEET

Rewrite the history

Modify the last commit.


Manage a tag
git commit --amend

List all the tags. Rebase the current branch onto a base.

git tag git rebase <bash>

Create a tag. Interactively rebase the current branch


onto a base.
git tag <tag-name>
git rebase -i <base>
Publish all the tags to the remote.
git push --tags

Delete a local tag.


Undo the changes
git tag -d <tagname>

Delete a remote tag. Revert a commit (by producing a new


git push --delete origin <tagname> commit with contrary changes).
git revert <commit>

Discard local changes in a specific file.


git checkout HEAD <file>
Manage a remote
Reset to a previous commit.
List all the remotes. git reset <commit>
git remote -v Discard all local changes.
Show information about a remote. git reset --hard HEAD
git remote show <remote>

Add a new remote.


git remote add <name> <url> Configure the GIT user

Remove a remote.
Define the author’s name.
git remote remove <name>
git config --global user.name <name>
Download all the changes from a remote
(without merging them into HEAD). Define the author’s email.

git fetch <remote> git config --global user.email <email>

https://timmousk.com/.

You might also like