Published Feb 27, 2012
I was using Subversion as software versioning and revision control system with my previous company. Hosting repositories with Subversion is not easy, and it is a centralized system where you can’t have your own local commits; and mergings within branches to trunk always a nightmare for me.
Hosting with Git is easy, and it is a distributed version control system where you can have your codes committed to local or remotes. Git copy all of the data containing branches, tags and stored locally in client’s system in order to switch between branches in seconds. With Git, you can work offline, by committing your codes locally and push to the remotes whenever you have internet connections.
SSH to the server, create the repository and create a bare Git repository.
$ mkdir test.git $ cd test.git $ git --bare init
That is all for the server side.
Open up Terminal, create a working directory, create an empty Git repository.
$ mkdir test $ cd test $ git init
We have created an empty Git repository. We will now add a file and commit the changes.
$ touch README $ git add README $ git commit -a -m 'first commit'
We have committed the changes. We will now setup the remote server and push to the server.
$ git remote add origin [email protected]:test.git $ git push origin master
That is all for the first commit. Each and every time you want to push the changes to remotes, you can just do
Code versioning makes our life easy! Try to start everything with
git init today!