Getting Started 。Init a repository ● Git init zachary@zachary-desktop:~/code/gitdemo$git init Initialized empty Git repository in /home/zachary/code/gitdemo/.git/ zachary@zachary-desktop:~/code/gitdemo$ls -1.git/ total 32 drwxr-xr-x 2 zachary zachary 4096 2011-08-28 14:51 branches -rw-r--r--1 zachary zachary 922011-08-2814:51 config -rw-r--r--1 zachary zachary 732011-08-2814:51 description -rw-r--r--1 zachary zachary 232011-08-2814:51HEAD drwxr-xr-x 2 zachary zachary 4096 2011-08-28 14:51 hooks drwxr-xr-x 2 zacharyzachary 4096 2011-08-28 14:51 info drwxr-xr-x 4 zachary zachary 4096 2011-08-28 14:51 objects drwxr-xr-x 4 zachary zachary 4096 2011-08-28 14:51 refs 16
Getting Started • Init a repository • Git init zachary@zachary-desktop:~/code/gitdemo$ git init Initialized empty Git repository in /home/zachary/code/gitdemo/.git/ zachary@zachary-desktop:~/code/gitdemo$ ls -l .git/ total 32 drwxr-xr-x 2 zachary zachary 4096 2011-08-28 14:51 branches -rw-r--r-- 1 zachary zachary 92 2011-08-28 14:51 config -rw-r--r-- 1 zachary zachary 73 2011-08-28 14:51 description -rw-r--r-- 1 zachary zachary 23 2011-08-28 14:51 HEAD drwxr-xr-x 2 zachary zachary 4096 2011-08-28 14:51 hooks drwxr-xr-x 2 zachary zachary 4096 2011-08-28 14:51 info drwxr-xr-x 4 zachary zachary 4096 2011-08-28 14:51 objects drwxr-xr-x 4 zachary zachary 4096 2011-08-28 14:51 refs 16
Getting Started ·A basic workflow Use your favorite editor Edit files zachary@zachary-desktop:-/code/gitdemo 四回☒ hello.txt Cirst line chird line Stage the changes Review your changes 一 Commit the changes Git Repoaitory HEAD Index e8 v file.txt 17
Getting Started • A basic workflow – Edit files – Stage the changes – Review your changes – Commit the changes • Use your favorite editor 17
HEAD Getting Started 。A basic workflow Git add filename Edit files -Stage the changes master Review your changes Commit the changes Git Repository HEAD Index Working Directory v file.txt vt file.txt zachary@zachary-desktop:~/code/gitdemo$git status On branch master Changes not staged for commit: (use "git add <file>..."to update what will be committed) git add (use "git checkout --<file>..."to discard changes in working directory) # modified:hello.txt # no changes added to commit (use "git add"and/or "git commit -a") 18
Getting Started • A basic workflow – Edit files – Stage the changes – Review your changes – Commit the changes • Git add filename zachary@zachary-desktop:~/code/gitdemo$ git status # On branch master # Changes not staged for commit: # (use "git add <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # # modified: hello.txt # no changes added to commit (use "git add" and/or "git commit -a") 18
HEAD Getting Started ·A basic workflow ● Git status -Edit files Stage the changes Review your changes Commit the changes Git Repository HEAD Index 6eio zachary@zachary-desktop:~/code/gitdemo$git add hello.txt v1 file.txt vt file.txt zachary@zachary-desktop:~/code/gitdemo$git status On branch master Changes to be committed: git add (use "git reset HEAD <file>..."to unstage) modified:hello.txt 19
Getting Started • A basic workflow – Edit files – Stage the changes – Review your changes – Commit the changes • Git status zachary@zachary-desktop:~/code/gitdemo$ git add hello.txt zachary@zachary-desktop:~/code/gitdemo$ git status # On branch master # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # modified: hello.txt # 19