This content originally appeared on DEV Community and was authored by Muhammad Ridho Anshory
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🍻
This content originally appeared on DEV Community and was authored by Muhammad Ridho Anshory
Muhammad Ridho Anshory | Sciencx (2022-02-20T23:07:19+00:00) Git Basic Commands. Retrieved from https://www.scien.cx/2022/02/20/git-basic-commands/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.