Skip to content

Single branch, single local repository work

benoitbleuze edited this page Aug 25, 2012 · 4 revisions

Single branch, Single local repository work

Here we will:

  • Create a repository
  • Add files to it
  • Check the status of the repo
  • Stage files for commit
  • Commit files

Create a repository

  • Initialise repository.
mkdir testRepo
cd testRepo
git init
Initialized empty Git repository in /home/ben/tmp/testRepo/.git/
  • Now use the most important git command you will ever use git status:
ben@GregoryHouse:~/tmp/testRepo$ git status
# On branch master
#
# Initial commit
#
 nothing to commit (create/copy files and use "git add" to track)

Start working in the repository.

  • Let's add a README file in the directory and see what happens:
git status
# On branch master
#
# Initial commit
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#	README
nothing added to commit but untracked files present (use "git add" to track)
  • As git status so helpfully states, let's use @git add@ to stage the file:
ben@GregoryHouse:~/tmp/testRepo$ git add README
ben@GregoryHouse:~/tmp/testRepo$ git status
# On branch master
#
# Initial commit
#
# Changes to be committed:
#   (use "git rm --cached <file>..." to unstage)
#
#	new file:   README
#
  • Please note again, that git status also tells you how to un-stage the file just added.
  • Finally let's record our changes, by committing them:
ben@GregoryHouse:~/tmp/testRepo (master #)$ git commit -m "First commit: add README"
[master (root-commit) 4a9deba] First commit: add README
 1 file changed, 6 insertions(+)
 create mode 100644 README

jump to Iterate and navigate through history

Clone this wiki locally