Git Source Code Management
Git is a fast, effective and user friendly source code management tool created by Linux Torvalds. All repository metadata is included on both the “client” and “server” including logs of all check ins, and changes.
Installing Git on CentOS
First thing is first, if we’re going to use git, we need to install it.
Install Git with yum
Now that we have git installed, lets navigate to a folder containing code. In this example, I’ll just use the wordpress tarball, extract it, and initialize a git repository in that folder. I’ll then clone that repository remotely on another CentOS machine, edit some files and commit my changes back to the server hosting the repo. I’ll then walk you through a few commands to view the history of commits, and then how to actually view the code changes.
Clone a git repository (plenty of projects on githubto check out)
Here we will clone the repo for django-allauth hosted on github
Update git repo to latest rev on server
This will download any changes made since you last ran this, or since it was initially checked out.
Configuration files are located in a hidden folder .git of the checked out repository.
If you have write access, you can modify the checked out code locally, and push it back to the server. Then when others run git pull, it’ll pull down the latest revision with your changes.
git add /path/to/folder/or/file
git commit -m "comment about the change you're pushing"
Revert your changes
If you clone a repository and make a bunch of edits that breaks stuff, you can revert back to the working version you initially checked out with.
If you made changes, and did a git add, only to realize it was in error use git reset from working directory of repo.
And if you have committed changes, but wish to revert it, you can use revert.
Check out the Git Wiki page and git homepage for more information.
If you’re working with sourcecode, and wish to make it a git repository, from the root working directory of the code use git init.
# initialize a bare shared repo
git init . --shared=true --bare
Working from a remote slave repo
# fetch updates from master
# push updates to the master repo