git push origin master:refs / heads / master这是干什么用的 [英] git push origin master:refs/heads/master what does this do

查看:292
本文介绍了git push origin master:refs / heads / master这是干什么用的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的gitolite存储库上创建一个新的repo时,我必须先输入以下命令,然后才能开始将代码推送到服务器。


$ b

git push origin master:refs / heads / master



它是做什么的?

我的猜测是与头部引用不确定有关。有人可以向我解释吗?

解决方案

这个命令有三个部分:

  git push 

这会调用push命令

 原产地

这个名称是您要推送的遥控器。这是存储在.git / config中的命名遥控器(可以用 git remote ),URL或标记列出。

这意味着当前的存储库。

  master:refs / heads / master 

这称为refspec,您可以在手册页中阅读 git push 。但总的来说,它由两部分组成,用冒号分隔。第一部分是本地分支的名称,第二部分是远程存储库上分支的名称(在本例中, origin )。这个特殊的refspec可以缩写为 master:master



通常,可以进一步缩短refspecs。只需指定 master 作为refspec就相当于在远程使用相同的名称,所以 master master:master


When I create a new repo on my gitolite repository I always have to enter the following command before I can start pushing code to the server.

git push origin master:refs/heads/master

What does it do ?

My guess is that is has to do with the head reference not sure. Could someone explain it to me?

解决方案

There's three parts to this command:

git push

This invokes the push command

origin

This names the remote to which you are pushing. This is either one of the named remotes stored in .git/config (you can list these with git remote), a URL, or the token . which means the current repository.

master:refs/heads/master

This is called a "refspec", and you can read about it in the man page for git push. But in general, it's comprised of two parts, separated by a colon. The first part is the name of a local branch, and the second part is the name of a branch on the remote repository (in this case, origin). This particular refspec could be shortened to master:master.

In general, one can shorten refspecs even further. Just specifying master as the refspec is equivalent to using the same name on the remote, so master is the same as master:master.

这篇关于git push origin master:refs / heads / master这是干什么用的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆