Git推拉起源大师不工作? [英] Git push and pull origin master not working?
问题描述
我目前正试图将我的一些项目文件推送到github上,但我现在正试图弄清楚什么是错误的,一直在盯着桌子。任何帮助将不胜感激。
我所做的是我首先在我的c:/目录中创建了一个名为cs188的新文件夹,并将我想要提交的所有文件该文件夹。我的目标是将我创建的整个cs188文件夹推送到github。
在git bash中,我输入:
(在cs188文件夹中):
git init
git add。
git commit -m第一次提交
现在我添加远程
git remote add origin https://github.com/my_username/myrepos.git
(myrepos是我在github上的仓库名称)
然后我输入: git push origin master
我收到一条警告,说明我当前分支的提示位于远程对象的后面,合并远程更改再次推送
。
现在我输入:
git pull origin master
但是,一旦完成,我的整个新文件夹已被替换为我的回购内容。
一旦我输入 git push origin master
,现在登录到我的github帐户,没有任何更改或添加过。
有没有人知道我在这里做错了什么?
为什么我的新文件夹是gett ing替换为我的存储库中的所有文件夹?
我应该怎样做才能摆脱当前分支的提示位于其远程对象后面,并让我的整个 cs188
文件夹在github上显示?
任何帮助都会被赞赏,我现在对github完全感到沮丧,真的可以使用一些帮助。
一个最简单的方法是: 第一次推送可以通过以下方式来完成:
git push -u origin master
之后,一个简单的 git push
就足够了。
请参阅 Git:为什么我需要一直做 - set-upstream
?。
注意:如果你的Github仓库不是空的,这个想法仍然有效:克隆它并添加你的文件。
否则,你需要关注无法pushto github,说不需要合并。
I'm currently trying to push some of my project files to github but I've been banging my head against the table now trying to figure out what is going wrong. Any help would be greatly appreciated.
What I do is I first created a new folder in my c:/ directory called cs188 and put all the files that I want committed in that folder. MY goal is to push the whole cs188 folder I created to github.
In git bash, I type:
(in the cs188 folder):
git init
git add .
git commit -m "first commit"
Now I add the remote
git remote add origin https://github.com/my_username/myrepos.git
(myrepos is the name of my repository on github)
Then afterwards I type:
git push origin master
I get a warning saying that "the tip of my current branch is behind its remote counterparts. Merge the remote changes before pushing again
".
So now I type:
git pull origin master
But once this is done, my whole new folder has been replaced with the contents of my repos.
And once I type git push origin master
, now and log onto my github account, nothing has changed or been added.
Does anyone have any idea what I'm doing wrong here?
Why is my new folder getting replaced with all the folders in my repository?
What should I do instead to get rid of "the tip of my current branch is behind its remote counterparts", and have my whole cs188
folder show up on github?
Any help is appreciated, I'm just completely frustrated with github right now and could really use some help.
One easiest way is to:
- clone your new empty GitHub repo
- add your file in that local clone, and commit
- push
The first push would be done with:
git push -u origin master
After that, a simple git push
will be enough.
See "Git: Why do I need to do --set-upstream
all the time?".
Note: if your Github repo wasn't empty, the idea is still valid: clone it and add your files in it.
Otherwise, you would need to follow "Cannot pushto github, keeping saying need merge".
这篇关于Git推拉起源大师不工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!