Beginner Essentials - I : Important Git Commands
linkinsunil.hashnode.dev
Hi! I am Sunil! I am a front-end developer.
If you're confused with lots of tutorials, youtube videos and unwarranted online knowledge about which GIT commands to know and which one to let go, you're in the right place. (TLDR? Go to point 1 below)
When I started learning web-development, I made various mistakes which most of the developers can relate to. We often see developers writing articles and making Youtube videos stating mistakes and ways to avoid them which are obvious to make in web development and programming.
Today I want to share some of my notes with you which I took while working on my front-end development journey which will be the "Beginner Essentials - I" i.e, all the extensively used Important GIT Commands. The "Beginner Essentials - II" covers the extensively used Important VSCode Shortcuts which increases developers productivity immensely and thus every developer wants to be well - verse with those. Make sure to check out both if you haven't already.
Now lets do some hands-on with the commands we were waiting for. Lets begin-
Essential GIT commands:
To execute Git commands, use a terminal (the built-in command line or Power Shell or Git Bash)
1. Git config
Git config is used to set up name and email that is associated with your GitHub account and link local machine to Github
git config –-global user.name “[name]”
git config -–global user.email “[email address]”
2. Git Init & GIt add
mkdir [directory name]
is used to make new directory (in windows)
cd [directory name]
is used to change directory to [directory name]
git init [repository name]
is used to initialize your repository
git add [file]
is used to add your repo into staging area
git add .
is used to add all files at once
03. Git commit
git commit -m “[ Type in the commit message]”
This command is used to commit your changes like file addition, deletion, any change etc into a staging area
04. Git log & Git status
git log
is used to check the history of the current branch
git status
is used to see the list of files that have to be committed
05. Git branch
git branch
is used to list all branches
git branch [branch name]
is used to create a new branch
git branch -d [branch name]
is used to delete branch
git checkout [branch name]
is used to switch from one branch to other
git merge [branch ]
is used to merge named branch in the current branch you are in
06. Git remote
git remote add [variable name ] [Remote Server Link]
This command is used to connect your local repository to a remote server
07. Git push & Git pull
git push [variable name] master
This command is used to send the local commit to the remote repository
git pull [Repository Link]
This command is used to fetch server commits to local commit
This is it. You're good to go and increase your productivity at work you ever wanted. If you find this piece of article useful, I'd definitely love to see you at my Linkedin and GitHub.