Git Commands
Posted on 2013-10-29 20:31:03 +0900 in Technique
Here is a useful tutorial for Git:Visual git guide
-
git statusCheck the status of the files.
-
gitk -all & git diffshow the branch in graphical mode.
check the difference.
-
git rmremove files
-
git log-
git log -p -2show the changing between the past two submitions
-
git log --onelineCondense each commit to a single line.
-
git log --statAlong 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 --amendreplace the last submit
-
git reset HEADunstage 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 -vshows the URL for the shorname to be expaned to
-
git remote show originlist the more infomation of the remote
-
git push origin local-branch-name:remote-branch-namepush to specilized banch
-
git push origin :newfeaturedelete remote branch newfeature
-
git merge --squash bugfix&git commit -m 'fix bug'Take all the commits from the
bugfixbranch, squash them into 1 commit and then merge it with themasterbranch -
git fetch origin & git checkout -b test origin/testfetch all the remote branches and checkout the specific branch
-
git branch -ashow the branch info in remote and local
-
git checkout --trackset the track branch
-
git rebasetake 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 listview the stash list
-
git stash apply stash@{2}apply the specified stash.
-
git stash apply --indexreapply the staged changes
-
git stash dropremote from the stash list
-
git stash popapply the stash and immediately drop it from the stack. Be causious.
-
git stash branchcreating a branch from a stash
-