Managing Software Projects with Git
Git, initially created by Linux kernel creator Linus Torvalds, was first
released in 2005 to host all development files for the Linux kernel. It is now
actively developed by a large team of developers led by Junio Hamano and is
widely used by many other open source projects.
Git works without a central repository, and it comes from a different
perspective than other version control systems while accomplishing the same
goals. Every directory that is tracked by Git acts as an individual repository
with full history and source changes for whatever is contained in it. There is
no need for central tracking. Source code control is done from the command
line, as shown in the following examples. You need to install Git from the
Ubuntu software repositories, where it is called git.
To create a new repository, access the top-level directory for the project and
enter the following:
Click here to view code image
matthew@seymour:~$ git init
To check out code from an existing central repository, you must first tell Git
where that repository is:
Click here to view code image
matthew@seymour:~$ git remote add origin
git://path_to_repository/directory/proj.git
Then you can pull the code from that repository to your local one:
Click here to view code image
matthew@seymour:~$ git pull
git://path_to_repository/directory/proj.git
To add new files to the repository, use the following:
Click here to view code image
matthew@seymour:~$ git add file_or_dir_name
To delete files from the repository, use this:
Click here to view code image
matthew@seymour:~$ git rm file_or_dir_name
To check in code after you have made changes, use the -m flag to add a note,
which is a good idea to help others understand what the commit contains:
Click here to view code image
matthew@seymour:~$ git commit -m 'This fixes bug 204982.'