Useful git commands for everyday use!
What is Git? It is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency. Nowaday, Git is very popular and familiar source with coders' community. In this post, I will recommand some useful git commands that can help you so much. Let's go!
Useful git commands
Init git project
Clone repo from link
git clone [link]
Save username, password
git config credential.helper store
Update code and write to local file
Pull new code but not write to file
git fetch origin <----this will fetch the branch git checkout branch_name <--- Switching the branch
Rename your local branch
If you are on the branch you want to rename:
git branch -m new-name
If you are on a different branch:
git branch -m old-name new-name
Delete the old-name remote branch and push the new-name local branch
git push origin :old-name new-name
Reset the upstream branch for the new-name local branch. Switch to the branch and then
git push origin -u new-name
git pull --recurse-submodules
git submodule update --remote --recursive
git stash git stash pop git checkout [file/folder] git checkout -f branch git branch
Lzdev always ready to support. Enjoy with Git!