Git Commands
Posted on 2013-10-29 20:31:03 +0900 in Technique
Here is a useful tutorial for Git:Visual git guide
-
git status
Check the status of the files.
-
gitk -all & git diff
show the branch in graphical mode.
check the difference.
-
git rm
remove files
-
git log
-
git log -p -2
show the changing between the past two submitions
-
git log --oneline
Condense each commit to a single line.
-
git log --stat
Along with the ordinary git log information, include which files were altered and the relative number of lines that were added or deleted from each of them.
-
-
git commit --amend
replace the last submit
-
git reset HEAD
unstage files
-
git add .
add all the files in the subdirectory.
-
git checkout \<file\>-
unmodifying a modified file, revert it back to what it looked like when last committed.
-
git remote -v
shows the URL for the shorname to be expaned to
-
git remote show origin
list the more infomation of the remote
-
git push origin local-branch-name:remote-branch-name
push to specilized banch
-
git push origin :newfeature
delete remote branch newfeature
-
git merge --squash bugfix
&git commit -m 'fix bug'
Take all the commits from the
bugfix
branch, squash them into 1 commit and then merge it with themaster
branch -
git fetch origin & git checkout -b test origin/test
fetch all the remote branches and checkout the specific branch
-
git branch -a
show the branch info in remote and local
-
git checkout --track
set the track branch
-
git rebase
take all the changes that were commited on one branch and replay on another one.
-
git rebase -i \<the SHA-1 of unchanged commit\>
merge multiple commits pick = use the commit squash = use commit, but merge into previous commit
-
-
git cherrypick <the SHA-1 of unchanged commit>
pick the specified commit to the current branch
-
git diff \<branch\> \<branch\>
compare the difference between two branches
-
git stash save 'comment'
save the changes temporary
-
git stash list
view the stash list
-
git stash apply stash@{2}
apply the specified stash.
-
git stash apply --index
reapply the staged changes
-
git stash drop
remote from the stash list
-
git stash pop
apply the stash and immediately drop it from the stack. Be causious.
-
git stash branch
creating a branch from a stash
-