Basic Git Command
This essential Git commands you must know if you are a
beginner in web dev….
Let’s start.
1. git config [options]
👉 Sets the
username and email address for commits.
git config –global
user.name “jag”
git config –global
user.email youremail@gmail.com
2. git init
👉 Initialize repository as git repository
git init
3. git clone
[url]
👉 Clone
repository from any server like Github Gitlab
git clone https://github.com/yourusername/hello.git
4. git status
👉 Check the
current status of working tree
git status
5. git add
[filename(s)]
👉Puts the unstage files to staging area
git add
index.js
git add .
6. git commit –m
[message]
👉 Records changes to the git repository
git commit –m
“make it better”
git commit –a
// commit all files without message
7. git remote
[options] [variables] [url]
👉Connect your local repo to remote over server
git remote add
origin https://github.com/yourusername/repo.git
8. git push [options] [variables] [branch]
👉Push the contents of your local repo to the remote repo
git push –u origin
main
9. git pull
[variables] [branch] [url]
👉 Fetch and
integrate the content of the remote repo to local repo..
git pull
origin main
git pull https://github.com/username/repo
10. git checkout [branch]
👉 Move from one branch to another
git checkout
roj
11. git
checkout [options] [branch]
👉 Create specific branch and simultaneously switches to it
git checkout –b
jagroj
12. git
branch [options] [branch]
👉 Performs operations over the specified branch
git branch –d
jagroj