Jaime Frutos Morales's blog


How to create and manage a Git repository

Filed under: SysAdmin — acidborg @ 15:05

Description: “Git is a free distributed revision control, or software source code management project with an emphasis on being fast. Git was initially designed and developed by Linus Torvalds for Linux kernel development. Every Git working directory is a full-fledged repository with complete history and full revision tracking capabilities, not dependent on network access or a central server.”

All the documentation about Git could be found here.


  • Ubuntu & Debian: apt-get install git-core
  • Fedora: yum install git

Git searches for its configuration files using this order (if one file is found, the rest are ignored):

  • .git/config : Repository-specific configuration settings
  • ~/.gitconfig : User-specific configuration settings
  • /etc/gitconfig : System-wide configuration settings

You can edit them directly or using the git config command. Examples:

git config --global user.name "Jaime Frutos Morales"
git config --global user.email "acidborg@gmail.com"

You can see all your current configuration settings using git config -l .

Creating a repository:

  • To create a repository in your current directory: git init

It will create a directory called .git in your current directory which contains the repository.

Adding and removing files:

  • To add a file or directory to your repository: git add file_name
  • To add all the files and subdirectories of your current directory to the repository: git add .
  • To remove a file from the repository: git rm file_name
  • To commit changes to the repository: git commit . In Git, adding a file to the repository and committing it are different actions, so after adding files to your repository, you have to commit them to save the changes. You will be asked to enter a short description of the commit in order to track the changes on the repository.
  • To see the status of your repository (files added, removed, committed, etc): git status

Viewing commits:

  • To list all the commits made to the repository: git log
  • To see the details of a specific commit knowing its ID (the sequence of letters and numbers after the commit word): git show commit_id
  • To list the changes made by the last commit: git show
  • To list a short description of all commits: git show-branch
  • To show the differences in files between two commits: git diff commit_id1 \ commit_id2

Create a free website or blog at WordPress.com.

%d bloggers like this: