-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
常用Git命令 #14
Labels
Command
Command line
Comments
新建本底仓库和远程同步
仅修改当前 repo
|
修改ignore文件之后的同步
|
Git 配置
|
Git tag
|
Git 删除历史记录
|
Submoduleshttps://git-scm.com/book/zh/v2/Git-%E5%B7%A5%E5%85%B7-%E5%AD%90%E6%A8%A1%E5%9D%97 添加子模块
获取子模块
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
1. Common
>>
git status // Show status of repo>>
git pull // Pull commit from binding remote branch>>
git add xxx.file // Add specific file to cache>>
git add ./ // Add all file to cache>>
git commit -m 'msg' // New commit with msg>>
git push origin : // Push new commit from local branch to remote branch>>
git stash // Store the data temporaryly>>
git stash pop // Pop out the data in stashChange the latest commit
>>
Modify the files>>
git add file-name>>
git commit --amend>>
Edit the commit message>>
git push origin local-branch:remote-branch -f2. Log
>>
git log // query current branch log tree>>
git log // query specific branch log tree>>
git log --author="Elvis Zhang" // query the commit info committed by Elvis Zhang>>
git log --pretty=oneline // Show the history briefly3. Rebase
>>
git pull rebase // Pull commit and apply in right order>>
git rebase -i HEAD~3 // Rebase last 3 commits Pick/Squash (Merge Commits)4. Branch
>>
git checkout // Switch branch>>
git branch // List branches>>
git branch // New branch with branch name>>
git branch -d // Delete the given branch, cannot be current branch>>
git checkout -b // New branch and switch to the branch>>
git merge // Merge the given branch to current branch>>
git cherry-pick // Merge given commit to current branch5. Clean
>>
git clean -f // Delete the untracked files6. Reset
>>
git reset --hard origin/ // Reset the cache and the commit>>
git reset --soft // Reset the commit and keep the modification.7. HEAD
8. RM
>>
git rm -r --cached . // Refresh cache. (In order to enforce the change of .ignore file)9. Remote
>>
git remote show // List all remote repo name [Always be used to sync official repo]>>
git remote add [name] [url] // Add a new remote repo>>
git remove [name] // Remove the current remote repo>>
git remote -v // List the remote repo name and url.10.Reflog
>>
git reflog // Show the git operation history11. Checkout
Branch Management
>>
git checkout -b new_branch_name // Create new branch and change to it.>>
git checkout new_branch_name // Change to the exsited branch12. Diff
>>
git diff // Compare the cache and working area.>>
git diff --cached […] // Compare the cache area and latest commit. [..] file name>>
git diff HEAD […] // Compare the working area and latest commit.>>
git diff commit-id […] // Compare the workinga area and given commit.>>
git diff --cached [] […] // Compare the cache and given commit.>>
git diff [] [] // Compare two commits.>>
git diff --HEAD > patch-name // Make the differences between the working area and latest commit as a patch. And can use commandgit apply patch-name
to apply patch.13. Branch
>>
git branch // Show existed branched>>
git branch -vv // Show binding relation between local branch and remote branch>>
git branch new_branch_name // Create new branch with branch_name and not switch.>>
git branch -d to_be_deleted_branch_name // Delete the branch with name (Not working branch)>>
git branch -D to_be_deleted_branch_name // Force delete the branch with name>>
git branch --set-upstream-to=origin/remote_branch_name // Bind remote branch and local branch.The text was updated successfully, but these errors were encountered: