If you have ever been active in the world of software development, you know the importance of keeping track of different versions of your project, which in turn helps you to keep that flow of development as well as to provide better usability. In addition, if you have ever approached experienced people in this field, they would prefer Git, in most cases. Technically speaking, Git is one widely used tool for distributed version control as well as source-code-management purposes with ease. On the other hand, GitHub is a hosting platform for software projects, which make use of Git for version controlling. So if you haven’t signed up for Github, we highly recommend you do so at https://github.com/signup/free.
All repositories in the basic plan of GitHub are public whereas you will have to purchase the premium plan for building private repositories. Rather than a hosting service, the service is something further useful, as it helps in building a community-level development as well as easy publicizing of your software-development projects, based on Git. When both these projects are combined together, it brings an awesome solution for the easy management of your projects. Earlier, we had published one tutorial for using Git in your Windows-powered PC. Now, it is time for Linux, which is also from the open-source power. Hope this tutorial will help you in setting up the special environment in your Linux PC and enabling version controlling in an effective manner.
Basics of Git
1. Creating a Repository
You can create a repository on Github, but you will need to be logged in on Github. If you don’t have an account, you can create one at github.com.
Here you need to provide a name for your repository, and some description. You can choose to make your repo Public or Private.
2. Set up Your Repository
Once, you have created the repo, Github will provide the instructions to setup your repo with on your local machine.
If you do not have Git setup on your machine, follow the instructions at https://help.github.com/articles/set-up-git. Now, let’s start with creating a directory and initializing Git.
Add a ‘index.php’ file to our directory.
< ?php echo "Hello git"; ?>
Now initialize the directory with:
$ git init
Add the files with:
$ git add
This will include all the files in our directory.
Now, let’s make our first commit with:
$ git commit -m "first commit"
Add the origin to our repository with:
$ git remote add origin [email protected]:bkvirendra/my-repo.git
Now lets, push the changes to our repository online:
$ git push
This will save all our local changes to our repository online.
That’s it, folks!
Please comment if you have any issues setting up Git on your local machine.