github提供了桌面客户端,我们也可以通过命令行的方式来进行控制。 windows mac



git config --global "username"
git config --global "email"



git init project-name
//create a new local repost with the specified name
git clone url
//download a project and its entire version history


git status
// list all new of modified files to be committed
git diff
//show file differences not yet staged
git add file
//snapshot the file in preparation for versioning
git diff --staged
//show file difference between staging and the last file version
git reset file
//unstage the file, but preserve its contents
git commit -m "description message"


git branch
//list all local branches in the current respority
git branch branch-name
//create a new branch
git checkout branch-name
//switch to the specific branch and update the working directory
git merge branch
//combine the specified branch's history into the current branch
git branch -d branch-name
//delete the specified branch


git rm [file]
//delete the file from the working directory and stage the deletion
git rm --cached [file]
//remove the file from version control but pressure the file locally
git mv [file-origin] [file-renamed]
//change the file name and prepare it for commit




git ls-files --other --ignored --exclude-standard
//list all ignored files in the project
git stash
//temprarily store all modified tracked files
git stash pop
//restore the most recently stashed files
git stash list 
//list all stashed changesets
git stash drop
//discard the most recently stashed changeset
git log
//list version history for the current branch
git log --follow [file]
list version history for a file
git diff [first-branch]...[second-branch]
//show content differences between two branches
git showw [commit]
//output metadata and content change of the specified commit
git reset [commit]
//undo all commits after[commit],preserve changes locally
git reset --hard [commit]
//discard all history and changes back to the specified commit
git fetch [bookmark]
//download all history from the respority bookmark
git merge [bookmark]