Git Basic Commands

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: sta…


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

  1. Git: configurations
  2. Git: starting a repository
  3. Git: staging files
  4. Git: committing to a repository
  5. Git: pulling and pushing from and to repositories
  6. 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


Print Share Comment Cite Upload Translate Updates
APA

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/

MLA
" » Git Basic Commands." Muhammad Ridho Anshory | Sciencx - Sunday February 20, 2022, https://www.scien.cx/2022/02/20/git-basic-commands/
HARVARD
Muhammad Ridho Anshory | Sciencx Sunday February 20, 2022 » Git Basic Commands., viewed ,<https://www.scien.cx/2022/02/20/git-basic-commands/>
VANCOUVER
Muhammad Ridho Anshory | Sciencx - » Git Basic Commands. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/02/20/git-basic-commands/
CHICAGO
" » Git Basic Commands." Muhammad Ridho Anshory | Sciencx - Accessed . https://www.scien.cx/2022/02/20/git-basic-commands/
IEEE
" » Git Basic Commands." Muhammad Ridho Anshory | Sciencx [Online]. Available: https://www.scien.cx/2022/02/20/git-basic-commands/. [Accessed: ]
rf:citation
» Git Basic Commands | Muhammad Ridho Anshory | Sciencx | 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.

You must be logged in to translate posts. Please log in or register.