Hi all, from this post I’m going to introduce you a distributed revision control and source code management system. Version Control System (VCS) is a software that helps software developers to work together and maintain a complete history of their work. From here on let’s talk about Git.
- You can install Git using the following command in LINUX.
sudo apt-get install git
- After that we can customize the Git environment by adding some information to it.
- Set user name :
git config --global user.name "vimukthis"
- Set email :
git config --global user.email "email@example.com"
- Avoid merge commits for pulling :
git config --global branch.autosetuprebase always
- Set color highlighting :
git config --global color.ui true
git config --global color.status auto
git config --global color.branch auto
- Set user name :
- Then we can list our customization using the following command.
git config –list
- After setting these customizations we have create a SSH public/private key pair.
- You can do it by using following command.
- After you share your public key with the server, now you are ready to connect to a repository. But don’t share your private key with anyone.
Now all the setup are done and now you are ready to work with Git. Let’s see some of the basic commands in Git.
- I want to get a project from a repository. ‘git clone‘ is used to that.
- From here on now you can work as usual, because now the project is on your local computer. Let’s view the files in the project.
- I’m going to create some directories and files inside the testing directory.
- Next we need to add the directory and files what we created to the staging area. We can do this using the ‘git add‘ command.
- After adding it to the staging area then we can commit it. Here the parameter ‘-m‘ will add a message to the commit as well.
- Then we can ‘push‘ all the changes to the server.
- Also using the ‘pull‘ command we can get updates from the server.
- There is a log file where you can see all the commits done by different users. You can view the log file by ‘git log‘ command.
- Then we can get more information about a commit using the commit ID taken from the log and use it with the ‘git show‘ command.
- Also if you want we can add tag with different information as well. Here the ‘-a‘ gives a name to the tag and the ‘-m‘ gives the message.
- Using the ‘-l‘ with the previous command we can view all the created tags. Here I have used it with ‘grep’.
- If you want to delete a tag, it is also possible with the ‘-d‘ parameter.
Here I have talked about some of the basic commands used in Git and installation of Git in a LINUX computer. Hope you are clear with Git. Hope to see you soon with another interesting blog post. Thank You!