Useful Git Commands
This post gives some useful Git Commands which will help you to play with a git repository.
What is Git?
Git is a program that helps to do version control. It is able to keep track of files. To keep track of file changes, GIT uses content snapshots, checksums and metadata. This is how Git providing version control. Git created by Linus Torvalds the one who created the Linux kernel.
Check below for some useful Git Commands:
How to clone a Branch:
git clone <url>
To create a branch:
git checkout -b <branch_name>
To show all branches:
How to add a change in the working directory:
git add <file>
To move to the master branch:
git checkout master
To pull updates: (Only Run from Master branch)
To move to the newly added branch:
git checkout <branch_name>
To get the difference:
git diff <file>
To get the status:
To save the changes:
git commit <file_name> -m "comment"
A commit in GIT is a state, actually the current state of files and the current commit is known as HEAD. Also, we can move the HEAD using different commands.
To commit all changes:
git commit -am "comment"
To push the changes:
git push origin <branch_name>
It will give a URL. Give that for merging.
To get the whole log:
To pull all files other than the changed ones:
This needs to be done inside the branch
git rebase master
Then, Push Your Changes:
git push -f
To delete a branch:
git branch -d <branch_name>
To delete a branch forcefully:
git branch -D <branch_name>
- Install and enable sudo command in Debian
- Understanding top Command
- Useful Qmail Commands
- Disable 2 factor authentication via command line in cPanel
- How to change cPanel password from command line
- Useful Exim Commands
- Useful Postfix commands Linux
- Check Internet Speed from the Linux Command Line
- Basic OpenVZ commands
- How to list connections on the server with netstat command
- How to use linux screen command
- How to change the file/directory permission using find command?
- Install GitLab on CentOS 7 and Derivatives
- How to enable GRE tunnel support in OpenVZ VPS
- How to Install BleachBit on Ubuntu and Derivatives
If you like the post Understanding top Command and wish to receive more articles from us, please like our FB page: GrepItOut
Your suggestions and feedbacks will encourage us and help to improve further, please feel free to write your comments. For more details on our services, please drop us an E-mail at email@example.com