Saturday, April 14, 2012

Git - Single Developer Mode

> git config --global user.name "david"
> git config --global user.email "dmak168@gmail.com"
> git config --global color.diff auto
> git config --global color.status auto
> git config --global color.branch auto

(make a repository)
> mkdir ~/Project
> cd ~/Project
> git init
> git status
> echo "Hello There!" > readme.txt
> git status
> git add readme.txt (add a new file)
> git commit
> git status
> git log

> echo "modified again" >> readme.txt
> git add readme.txt (the second add put readme.txt into staging area)
> git reset (this is to reset staging area which result in doing nothing when commit)
> git add readme.txt
> git commit (this is to commit change to the repository)
(if you don't want to use "git add" for every change you made to a file
then you can just use "git commit -a" which will by pass the staging area)

Note 1:
1. Subversion works on repository and repository is represented as number starts at 1.
2. CVS works on File and each version of file is represented as 1.1, 1.2, 1.3 ...
3. Git works on commit, each commit gets a number (SHA1 hash) - which can guarantee the content of the repository. It promises that what we put in is what we get out by using the unique hash number.

Note 2:
> git reset (will not remove your changes but just reset the staging which means cannot commit)
> git reset --hard (will reset staging and also remove your changes and put it back to its last commit)

Note 3:
In Git our working copy is a local copy which is a full repository, and the commit is a local commit.


No comments: