Samstag, 30. August 2008

Git CheatSheet















.gitignore contains the ignore files (add *.log, .DS_Store, config/database.yml)
>git init
>git add .
>git add "file name"
>git status
>git --global user.name "name"
>git --global user.email "email"
>git --global apply.whitespace nowarn
>git commit -m "message describing this commit" or git commit -v (shows you the diffs done and lets you write your commit mesage)
>git commit -a (commit all files that have been changed)
>git commit -a -v (commit all files and show diffs that have been changed)
>git log (give ascii log with messages)
>git log --stat (ascii output graph of the file changes with + and -)
>git log --p (see the diffs of the files)
>gitk (launch a visual tool of the git log). >gitk & to run in the background
>gitk -all (all local and remote branches)

>git branch (show the current branches)
>git branch --color (shows local and remote branches in color)
>git branch "name of branch" (creates a new branch)
>git branch -a (shows all local and remote branches)
>git checkout "name of branch" (to work on the named branch)

>git rebase "name of another branch" (get current changes from another branch into my working branch)
>git diff "branch 1" "branch2" (show the diffs of 2 branches) or pipe to TextMate with git diff "branch1" "branch2" | mate
>git merge branch (merges branch into current branch)
>git reset --hard ORIG_HEAD (revert the merge)
>git stash "message" (save current status of work to a "clipboard")
>git stash list (show the contents of the clipboard)
>git stash apply (bring the status in the clipboard)
>git branch -d branchname (delete a previously merged branch)
>git branch -D branchname (delete a non merged branch)
>git stash clear (clearsout the stach clipboard)

Repositories
copy project to another machine (cp -r or scp -r)
>git clone remotemachineurl (gets a copy of the remote repository from the remote machine)
>git fetch (get a copy of all objects from the remote machine - don't merge with local machine)
>git pull (syncronizes fetches changes from the remote machine with the local machine with the branch I am currently in)
>git push (syncronize local changes back to the remote machine)
>git merge (local merging of 2 branches)
>git remote show name_of_repository (shows some info on the branches in the remote repository)

Keine Kommentare: