About this article
In this article, I will share with you guys what are the basic commands when using git CLI.
I know who did what, when, and why. -Git
Table of Contents
- Git: configurations
- Git: starting a repository
- Git: staging files
- Git: committing to a repository
- Git: pulling and pushing from and to repositories
- Git: branching
Git: configurations
git config <followed with>
followed with:
--global user.name "FirstName LastName"
--global user.name "yourEmail@email.com"
--global color.ui true
--list
Git: starting a repository
git init
git status
Git: staging files
adding files to staging area
git add <fileName>
git add <fileName> <anotherFileName>
git add .
git add --all
git add -A
removes a file from the staging area
git rm --cached <fileName>
discard change or reset the file
git reset <fileName>
Git: committing to a repository
Appendix:
-m โ stands for a message
git commit -m "Add three files"
undo the last Git commit
git reset --soft HEAD^
Git: pulling and pushing from and to repositories
Appendix:
-u โ add upstream (tracking) reference
git remote add origin <link> //Adding a remote repository
git push -u origin master //pushes all your branches to the origin.
git clone <cloneURL> // clone a repository
git pull // download all the changes
Git: branching
git branch // current branch
git branch <branchName> // create a branch
git checkout <branchName> // change current branch
git merge <branchName> // merge branchName to current branch
git checkout -b <branchName> // create and checkout a new branch
If you guys have other thoughts leave a comment I'll update the post base on your solutions as well.. cheers๐ป
Top comments (1)
Awesome cheat sheet. I would use the more modern
git switch <branchName>
instead of thecheckout
command that you mentioned.