For every developer, git is a must-use tool for daily work. May it be work or side projects, one must know how to work with git.
Let's look at some commands that are essential for you.
- init - used to initialize a git repo on your local machine
git init
- clone - clones a remote repo to your local machine
git clone <repo-url.git>
- pull - fetch latest changes from the current remote repo to your local
git pull origin <branch-name>
- push - moves your local changes to the remote repo
git push origin <branch-name>
- checkout - switch to a new branch
git checkout <branch-name>
- checkout -b - creates a branch if unavailable and then switches
git checkout -b <branch-name>
- branch - lists all branches
git branch
- branch name - creates a new branch
git branch <branch-name>
- branch -d - deletes a branch
git branch -d <branch-name>
- add - moves your changes to the staging area
git add <filename1, filename2>
or
git add .
(to add all files)
- commit - commits your changes and creates a commit history
git commit -m "commit message"
- branch -M - renames branch
git branch -M <new-name>
These are the basic commands that you will b using in your day-to-day work. There are some advance commands that you move to when you get yourself familiar with the above commands. Few commands are as follows -
git rebase
git cherry-pick
git log>file
and many more...
That's it for this one. Hope you learned something. Thanks for reading.
Follow for more.