Git

Git commands cheat sheet

In this article, I am going to share common git commands, that you need every day. I will be adding commands continuously. So, bookmark this page this will help you a lot.

Git Clone
git clone https://YOUR-REPOSITORY
Connecting your existing repository to Git
git remote add origin https://[Your-repo-url-here]
git checkout BRANCH_NAME
Commit all changes
git commit . -m "Here you commit message"
Commit a new folder with files inside it
git add FOLDER_NAME
git commit -m "COMMIT NEW FOLDER"
Push your changes to a branch
git push origin [Bnrach_NAME]
List your all branches
git branch -a
To check your current branch (Please note that your branch would have * at the start. For example if you are on master => * master)
git branch
Delete a Local GIT branch
git checkout BRANCH_NAME
Delete a remote GIT branch
git push -d origin <branch_name>
Git stash with name
git stash save "Name stash here"
List existing Stashes
git stash list
Apply stash (Find number from above command)
git stash apply stash@{0}
Setting or Changing remote URL
git remote set-url origin [REPO URL HERE]
Create a branch and push to remote
git checkout -b [BRANCH NAME]
git push -u origin [BRANCH NAME]

These are a few commands. I will be adding more git commands frequently.

Please share this post:
Distinguished Engineer Java, PHP, Spring, Mysql
Posts created 11

Ask a Question

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Related Posts

Begin typing your search term above and press enter to search. Press ESC to cancel.

%d bloggers like this: