Version 8 (modified by dukeleto, 12 years ago) |
---|
checkout
To check out a repo:
git clone git://github.com/leto/parrot.git
There should now be a directory called "parrot" in your current directory.
commit
Next we modify a file so we can commit a change:
echo "Some junk" >> README
To see a list of modifies files:
git status
should produce something like
# On branch master # Changed but not updated: # (use "git add <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # # modified: README #
To commit all local changes:
git commit -a -m "I did some stuff"
If you had multiple changed files that you wanted to commit seperately, you would do
git add README git commit -m "I commit stuff"
LESSON: Git only commits files you have added already. The -a flag lets you be lazy and say "go ahead and add all modified files" when you are commiting.
log
git log -10 to see the commit message and metadata for the last 10 commits.
git log -p to see the commit history as a series of patches .
You can give git log a file name or directory or a branch name. Very useful!
update
The equivalent of "svn up" is
git pull
list branches
To see a list of current local branches:
git branch
To see all local and remote branches:
git branch -a
create a branch
Suppose you want to create a local branch to work on your latest and greatest new feature. To create a new branch and check it out all in one automagical command:
git checkout -b new_branch
If you want to create the branch and check it out seperately (maybe because you want to do something else in between or batch the creation of many branches/etc..)
git branch some_branch
Later on, you can checkout some_branch with:
git checkout some_branch
switching branches
Let's say you are on new_branch but you want to go back to the master branch:
git checkout master
merge
To merge the foobar branch into the current branch:
git merge foobar
praise/blame
Git has everyone's favorite VCS command, blame!
git blame somefile