Skip to content

Instantly share code, notes, and snippets.

@amirex128
Last active April 22, 2022 13:19
Show Gist options
  • Save amirex128/625581ee4933db259c251fd296f39be5 to your computer and use it in GitHub Desktop.
Save amirex128/625581ee4933db259c251fd296f39be5 to your computer and use it in GitHub Desktop.
Git Cheet Sheet
Git add .
Move to Stage
Git restore --staged
Move stage file or code to unstage
Git restore
Remove last change from stage (first your code must move to stage)
Git status -s
Show brief of status
Git log
Show all change log
Git log --oneline
Show all change log brief
Git log --oneline --graph --all
Show all log with graph
Git config --list
Show all git's config
Git remote add [name of remote] [address of remote]
Add new remote repository
Git remote
Show list of remote
Git push -u [name of remote] [name of branch]
Push commit to specific remote and branch
Git branch
Show local branch
Git branch -a
Show all branch
Git branch [branch name]
Create new branch from current branch
Git checkout -b [branch name] [branch you want copy them]
Create new branch from current branch and switch to them
Git checkout [branch name]
Switch to another branch
Git branch -d [branch name]
Delete a branch
Git branch -D [branch name]
Delete a branch with yourself commit without merge to master (force delete)
Git branch -m [old name] [name name]
Change branch name
Git push -d [remote name] [branch you want delete]
Remove remote branch
Git merge [source branch] [destination branch]
Merge branch (you must login to destination branch for marge operation)
Git rm --cached [file name]
Remove file from repository and add into untrack (now you must add this file to gitignore)
Git clone -b [specific branch name] [url git repository]
Clone a specific branch from repository
Git stash
Add your code to stash with last commit name (all file move to stash except untracked file )
Git stash save "message"
Add your code to stash with specific message (all file move to stash except untracked file )
Git stash list
List of stash
Git stash show [stash id]
Show details of stash
Git stash apply [stash id]
Recover stash changes
Git stash drop [stash id]
Remove stash ) stash aren't deleted after apply)
Git stash pop [stash id]
Apply and drop stash
Git stash branch [branch name] [stash id]
Create new branch from stash (create new branch - switch branch - apply stash changes - drop stash)
Git tag
List of tags
Git tag [tag name]
Create new tag last commit
Git tag -a [tag name] -m "message tag"
create annotate tag for last commit
Git tag -a [tag name] -m [message] [commit id]
Create tag for specific commit
Git push [remote name] [tag name]
Send tag to remote repository
Git tag -d [tag name]
Remote tag
Git push [remote name] -d [tag name]
Remote tag from remote repository
Git commit --amend --no-edit
Add last change to last commit
Git rebase [branch name]
Rebase current branch to another branch (you must checkout to that branch want rebase)
Git fetch [remote] [branch]
Update status and log
Git reflog
Show all changes log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment