<span class="token comment"><span class="hljs-comment"><span class="hljs-comment"># 显示某个远程仓库的信息
$ git remote show <span class="token punctuation">[remote<span class="token punctuation">]
<span class="token comment"><span class="hljs-comment"><span class="hljs-comment"># 增加一个新的远程仓库,并命名
$ git remote add <span class="token punctuation">[shortname<span class="token punctuation">] <span class="token punctuation">[url<span class="token punctuation">]
<span class="token comment"><span class="hljs-comment"><span class="hljs-comment"># 取回远程仓库的变化,并与本地分支合并
<span style="color: #ff0000">$ git pull <span class="token punctuation"><span style="color: #ff0000">[remote<span class="token punctuation"><span style="color: #ff0000">] <span class="token punctuation"><span style="color: #ff0000">[branch<span class="token punctuation"><span style="color: #ff0000">]
<span class="token comment"><span class="hljs-comment"><span class="hljs-comment"># 上传本地指定分支到远程仓库
<span style="color: #ff0000">$ git push <span class="token punctuation"><span style="color: #ff0000">[remote<span class="token punctuation"><span style="color: #ff0000">] <span class="token punctuation"><span style="color: #ff0000">[branch<span class="token punctuation"><span style="color: #ff0000">]
<span class="token comment"><span class="hljs-comment"><span class="hljs-comment"># 强行推送当前分支到远程仓库,即使有冲突
$ git push <span class="token punctuation">[remote<span class="token punctuation">] <span class="token operator">--force
<span class="token comment"><span class="hljs-comment"><span class="hljs-comment"># 推送所有分支到远程仓库
$ git push <span class="token punctuation">[remote<span class="token punctuation">] <span class="token operator">--all
九、撤销
$ git checkout <span class="token punctuation">[commit<span class="token punctuation">] <span class="token punctuation">[file<span class="token punctuation">]
<span class="token comment"><span class="hljs-comment"><span class="hljs-comment"># 恢复暂存区的所有文件到工作区
$ git checkout <span class="token punctuation">.
<span class="token comment"><span class="hljs-comment"><span class="hljs-comment"># 重置暂存区的指定文件,与上一次commit保持一致,但工作区不变
$ git reset <span class="token punctuation">[file<span class="token punctuation">]
<span class="token comment"><span class="hljs-comment"><span class="hljs-comment"># 重置暂存区与工作区,与上一次commit保持一致
<span style="color: #ff0000">$ git reset <span class="token operator"><span style="color: #ff0000">--hard
<span class="token comment"><span class="hljs-comment"><span class="hljs-comment"># 重置当前分支的指针为指定commit,同时重置暂存区,但工作区不变
$ git reset <span class="token punctuation">[commit<span class="token punctuation">]
<span class="token comment"><span class="hljs-comment"><span class="hljs-comment"># 重置当前分支的HEAD为指定commit,同时重置暂存区和工作区,与指定commit一致
$ git reset <span class="token operator">--hard <span class="token punctuation">[commit<span class="token punctuation">]
<span class="token comment"><span class="hljs-comment"><span class="hljs-comment"># 重置当前HEAD为指定commit,但保持暂存区和工作区不变
$ git reset <span class="token operator">--keep <span class="token punctuation">[commit<span class="token punctuation">]
<span class="token comment"><span class="hljs-comment"><span class="hljs-comment"># 新建一个commit,用来撤销指定commit
<span class="token comment"><span class="hljs-comment"><span class="hljs-comment"># 后者的所有变化都将被前者抵消,并且应用到当前分支
$ git revert <span class="token punctuation">[commit<span class="token punctuation">] (编辑:瑞安网)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|