Updating your GitHub.com Fork

Github.com hosts a large number of open source repositories. You can often fork these repositories, however keeping the fork updated with the master¬†can be challenging. Here are some steps you can do to update your fork with the master. The below assumes you are in your local fork directory.¬†Also, the branch from the master is called ‘develop’, if it is something else, then use that branch name instead of ‘develop’. I am using the SaltStack repo as an example.

$ git remote -v
$ git remote add upstream https://github.com/saltstack/salt
$ git remote -v
$ git fetch upstream
$ git checkout develop
$ git merge upstream/develop
$ git push

Git on CentOS

Git is very popular source code management (SCM) system. It has replaced SVN as the preferred choice of coders. In this brief tutorial I will show you how to setup Git on your CentOS box, and start using it. First, install Git from source code, primarily because if you install from the yum repos you might get an older version. Git requires the following packages:

sudo yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel -y

I already had a previous version of Git installed, so I was able to download Git source using Git. If you do not have Git installed, then you can install it using ‘sudo yum install git -y’.

git clone https://github.com/git/git.git

Uninstall the old version of git, so that you can use the new version which you will build below.

sudo remove git -y

Now install some tools needed to make git:

sudo yum install make -y
sudo yum install gcc -y
sudo yum install cpan -y 
sudo yum install perl-DBI perl-DBD-MySQL -y #For MakeMaker

We are now ready to actually install Git, which is done as follows:

sudo make prefix=/usr/local all
sudo make prefix=/usr/local install

Now that you have Git installed, visit github.com and create your free account. After that create a repo on Github.com using the steps here https://help.github.com/articles/create-a-repo. Next in your shell we will clone the above repo and create a file in it.

mkdir -p git && cd git
git config --global user.name "syedaali"
git config --global user.email "youremailaddress@yahoo.com"
git config --global credential.helper cache
git config --global credential.helper 'cache --timeout=7200'
git clone https://github.com/syedaali/perlex.git
cd perlex
touch README
git add README
git commit -m "Adding README"
git push

Using git config I specified my username which I had created on GitHub.com. I also specified that git should cache my credentials for 7200 seconds, so that I do not have to enter my username and password repeatedly. On Github.com I had created a repo called perlex.git, I cloned that using the ‘git clone’ command. After that I created a file called README, committed it to my local repo and then pushed it to the remote Github.com repo. For further reading visit http://git-scm.com/documentation.