Managing software development projects with Git


A Git-versioned project keeps three versions of a file. The version in the working directory is the one you work on. Once the file has reached a state that you want to keep, transfer it to the staging area using git add file and continue working on the version in the working directory.

You can repeat this process as often as you like. However, you always overwrite the previous version in the staging area. There is exactly one version for each file in the staging area. Any following commits adopt this latest version. The version in the working directory is irrelevant.

Figure 2 shows two different versions of the file project.txt, one in the staging area and a second in the working directory. The repository contains the third version.

Figure 2: Two versions of a file and possibly instructions for working with them.

Git sometimes gives hints when executing some commands. The hints often refer to how you undo a particular action.


In addition to the general manual (man git), the installation comes with several specific manuals (see Table 1). If you call man git, you will find an overview of the subcommands, including a short description in the GIT COMMANDS section (Figure 3).

Table 1

All Cases Covered



man gittutorial

Git-based project flow

man giteveryday

Frequently used commands, including examples (Fedora)

man gitcore-tutorial

Procedure in detail; partly using outdated commands

man git

General manual

Figure 3: The man git man page gives you a quick overview of git commands.

Further documentation is located in /usr/share/doc/git. The scope of the documentation depends on the distribution. Fedora comes with a manual for users, user-manual.html, and a how-to, howto-index.html.

For help with a subcommand, add the subcommand with a hyphen. For instance, man git-add brings up information on the git add command (Figure 4).

Figure 4: In addition to a page with general information, many distributions also have pages explaining the various subcommands.

All distributions used in the test support automatic completion of the Git commands and their options using the Tab key. The excerpt from Listing 4, Line 2, shows the output after the command git a followed by pressing Tab. In this case, several options appear. The call to git --help (Listing 4, Line 3) shows an excerpt from the overview of the Git commands by task.

Listing 4

Completion and Help

01 $ git a
02 add    am    annotate    apply    archive
03 $ git --help
04 Use: git ... <command> [<args>]

Continuing with the Project

The project.txt file changes as the project progresses. You copy and save new versions with the commands add and commit. The git status command shows the status of the files in the working directory. Listing 5 shows the status of the file after the git add project.txt command switches from changes that are not flagged for a commit to changes that are flagged for commit.

Listing 5

Project File Status

$ echo "new line" >> project.txt
$ git status
On Branch master
Changes not flagged for commit:
  (use"git add <File>..." to flag the changes for the commit)
  (use "git checkout -- <File>..." to discard the changes in the working directory)
        changed:       project.txt
no changes are flagged for commit (use "git add" and/or "git commit -a")
$ git add project.txt
$ git status
On Branch master
changes flagged for commit:
  (Use "git reset HEAD <File>..." to remove from the staging area)
        changed:       project.txt
$ git commit -m "new line inserted"
[master 9d71c8d] new line inserted
 1 file changed, 1 insertion(+)

The git add command lets users specify patterns for files and directories and other options. You can use git add -u to move all modified files entered in the index into the staging area. Table 2 shows the commands used so far.

Table 2

Getting Started




Create or initialize empty repository


Add files to the staging area (basis for a commit)


Transfer staging area versions to repository


Request status of files in working directory

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Git Ready

    If you develop open source software, you need to know how to use Git. Information on Git fills books, but this basic overview will get you started with a vital open source development tool.

  • Workspace: Subversion

    Even if you are not a programmer, you’ve probably heard of Subversion, a powerful tool for managing changes to software projects. Although Subversion is designed primarily for software developers, it can be useful to mere mortals as well.

  • Tree View

    Complex Git projects sometimes require a better view of the dependencies and branches. Several tools offer GUI options for Git. We take a look at gitk, gitg, git-gui, and GitAhead.

  • Branch Management

    Git makes version control as simple as possible. To manage your Git branches successfully, you need to learn the ins and outs of git branch and git merge.

  • Remote Git Repositories

    Software projects often comprise several code branches, some of which exist in parallel. Git supports community code development through remote repositories and code branching.

comments powered by Disqus

Direct Download

Read full article as PDF:

Price $2.95

Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Find SysAdmin Jobs