We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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 branch -a
git branch 新分支名 例如,在master分支下,新开一个开发分支: git branch dev
git checkout 分支名 例如,在master分支下,切换到新开的dev: git checkout dev
git checkout -b 新分支名 例如,新开一个开发分支,并立即切换到该分支: git checkout -b dev
git checkout 原分支名 例如,切换回master git checkout master 注意:当前分支有修改,还未commit的时候,会切换失败,应当先commit,但可以不用push
git merge 需要合并的分支名 例如,刚刚已经切换回master,现在需要合并dev的内容: git merge dev 建议在GitLab(或者其他git系统)上面创建merge request的形式来进行分支的合并和代码审核。
git branch -a 前面带remotes/origin 的,是远程分支
git branch -r
git push origin 新分支名 例如,刚刚在master下新开的dev分支: git push origin dev
git push origin :远程分支名 例如,删除刚刚提交到远程的dev分支: git push origin :dev
git branch 分支名称 -d 例如,在master分支下,删除新开的dev分支: git branch dev -d 注意:如果dev的更改,push到远程,在GitLab(或者其他git系统)上面进行了merge操作,但是本地 master没有pull最新的代码,会删除不成功,可以先git pull origin master,或者强制删除 git branch dev -D
git fetch -p
$ git remote -v
$ git remote add [name] [url]
$ git remote rm [name]
$ git remote set-url --push [name] [newUrl]
$ git pull [remoteName] [localBranchName]
$ git push [remoteName] [localBranchName]
$ git push -f
The text was updated successfully, but these errors were encountered:
No branches or pull requests
git 命令用法
1. 查看项目的分支们(包括本地和远程)
2. 开分支
3. 切换到新分支
4. 开分支和切换分支合并到一个命令
5. 切换回原分支
6. 合并分支
7. 查看本地分支列表
8. 查看远程分支列表
9. 向远程提交本地新开的分支
10. 删除远程分支
11. 删除本地分支
12. 更新分支列表信息
查看远程仓库:
添加远程仓库:
删除远程仓库:
修改远程仓库:
拉取远程仓库:
推送远程仓库:
强制推送
The text was updated successfully, but these errors were encountered: