# Git cheatsheet

`git init` : initialize an empty Git repository

`git clone <repository_url>` :clone an existing Git repository

`git add .` : add all the files/directory files to git

`git commit -m "message"` :commit all the staged files to git

`git status` : show the status of your Git repository

`git remote -v` :show remote origin URL

`git remote add origin <your_remote_git_url>` :add remote origin URL

`git push origin <branch_name>` :push your local changes to remote repository

`git log` : show logs of git commit

`git reset <commit_id>` :the commit id is removed from the history and the files related to it get unstagged

`git remote add upstream <URL>` : to set upstream URL

TAG COMMAND

`git tag <tag_name>` create lightweight tag

`git tag -a <tag_name>` to create an annotated tag

`git tag` : to list all the stored tags in the repo

`git push origin <tag_name>` : push tag to the remote repository

BRANCH COMMAND

`git branch` : show all the branches of git repo

`git checkout <branch_ name>` : checkout to an existing branch

`git checkout -b <branch_name>` : checkout to a new branch

`git branch -d <branch_name>` : remove a branch from git

`git branch -m rename branch` :to rename a branch

STASH COMMAND

`git stash` :to stash staged item

`git stash -u` : to stash staged/un-tracked items

`git stash pop stash@{n}` : remove the changes from stash and apply them to working files

`git stash apply stash@{n}` :To apply a stash and keep it in the stash cache

`git stash list` :show git stash history

`git stash branch` :stash work on a separate branch

`git stash drop` :drops the top stash

***Thank you for reading!!***

[**~Sujata Kumari**](https://www.linkedin.com/in/sujata-kumari-673374194/)
