Git is a versioning system developed by Linus Torvalds, the founder of Linux. Git is used my millions of people across the globe. It is a perfect replacement to subversion, another Linux versioning system. In this tutorial we will learn how to setup and configure own Git server on CentOS 6.x.
Git is available in the CentOS default repository. We can install it using the following command.
yum install git
This will install Git along with all its dependencies. Once it is installed we will proceed towards the setup.
It is recommended to provide your name and email address. Following are the commands to set the same.
git config –global user.name “Your Name Here”
git config –global user.email “[email protected]”
The configuration changes will be stored in a file in your home directory. It can be seen by any editor or a simple cat command
The output will be something like
name = Your Name Here
email = [email protected]
This information can be also viewed by querying git.
git config –list
user.name=Your Name Here
If the above details are not filled, then they will be filled automatically.
Now we will create our first Git repository.
1. Logon to the server using root.
2. create a new directory
3. Now we will create our first git directory inside the directory created in step 1.
4. Now, we will change the working directory to the newly created directory.
5. Now it’s time to initialize the directory.
We will now create the initial repository on the client machine.
Add a file
Now add the new file to the repository.
git add TEST
Commit the changes
Now, we will add the address of the remote repository
git remote add origin ssh://[email protected]_server/home/git/first_directory.git
Now push the commit to the remote repository.
git push origin master