git提交问题 [英] git commit problems

查看:89
本文介绍了git提交问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚提交了我的工作树,首先添加到索引中,使用$ git commit -m'test'我将stdout-put从此保存到文件中,并且在顶部看到它说



I just commited my working tree, added to index first, with "$git commit -m 'test'" I saved the stdout-put from this to a file and I see at the top of it that it says

# On branch master  
# Changed but not updated:  
# (use "git add/rm ..." to update what will be commited)  
# (use "git checkout -- ..." to discard changes in working directory)"  

问题是我的工作树没有被委托给repo,而且我有一种感觉,这与它有关。

the problem is that my working tree is not being commited to the repo, and I have a feeling this has something to do with it

感谢

thanks

推荐答案

简短回答:



git push -u origin master

你很可能试图将提交推送到尚未创建的分支 - 例如,在未创建自动创建的README文件的新创建的Github存储库中,通过调用 git push -u origin master ,你的规格如果你需要推送到远程(源,通常是git默认值)和分支(主,在典型情况下也是默认值)。根据git文档:

You're most likely trying to push commits to a branch that wasn't created yet - for example, on a newly created Github repository without the README file automatically created. By calling git push -u origin master, you specify both the remote that you need to push to (origin, which is usually the git default) and the branch (master, also default in typical cases). According to the git documentation:


-u - set-upstream
对于每个最新或成功推送的分支,添加上游(跟踪)引用,用于无参数git-pull(1)和
其他命令。有关更多
的信息,请参阅branch..merge in git-config(1)。

-u, --set-upstream For every branch that is up to date or successfully pushed, add upstream (tracking) reference, used by argument-less git-pull(1) and other commands. For more information, see branch..merge in git-config(1).

这意味着在成功运行这个命令,从那时起你就可以使用 git push git pull ,它会默认为原始大师(带有一些例外)。

This means that after a successful run of this command, from then on you'll be able to just use git push and git pull and it will default to origin master (with some exceptions).

这篇关于git提交问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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