x + y; } int deleteFile(char *filename) { // delete a file } int add(int x, int y) { // adds x and y return x + y; } int deleteFile(char *filename) { } Bob Alice Tuesday, March 6, 2012
All data is stored locally A client keeps a ‘workspace’, only a single state Each client keeps entire project history Server is required for every operation Server is only required for collaboration Tuesday, March 6, 2012
main.c # Add all files in current directory to the changelist git add . # Add all .cpp files to the change list git add *.cpp # Insert a Remove File command to the change list git rm mistake.cpp # Insert a Rename command to the change list git mv persons.cpp people.cpp Tuesday, March 6, 2012
Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # #! renamed: include/entry.h -> include/contact.h #! renamed: src/entry.c -> src/contact.c # # Untracked files: # (use "git add <file>..." to include in what will be committed) # #! include/photo.h #! resources/ #! src/photo.c > git commit Tuesday, March 6, 2012
Date: Thu Feb 16 07:46:18 2012 +0200 New Feature: User photos commit d70f574d2f6a3a67de69ee58a2e27daff4c6b10e Author: ynonp <[email protected]> Date: Thu Feb 16 07:40:56 2012 +0200 First commit Tuesday, March 6, 2012
status • Use git log to list history • In the log, each entry has a commit number. Use git checkout d70f To go back a given commit number Tuesday, March 6, 2012
temporarily restore state to that commit • Making changes to a past state will open a new branch • Use git checkout master to go back to head • Always commit or reset changes before checking out Tuesday, March 6, 2012
new branch named feature • Use git checkout feature to switch to the new branch • Use git checkout -b d70f to start a new branch from old commit • Use git branch for info Tuesday, March 6, 2012
client calls. # She found a bug in release d70f # Commit all active work git commit -a # Create a new branch called fixes starting from commit d70f git checkout -b fixes d70f # Fix bug ... # Commit your newly fixed code git commit -a # Get back to work git checkout master Tuesday, March 6, 2012