从git init开始,Git推送到远程仓库 [英] Git push to remote repository started with git init

查看:145
本文介绍了从git init开始,Git推送到远程仓库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有VS解决方案的文件夹,只有很少的项目,等等。我创建了一个GitHub仓库,并通过Web界面上传了该目录的内容。
现在,对我的项目进行了更改,我想开始将这些项目推送到我的github存储库。所以我使用 git init ,而不是阶段文件和提交文件。

但是我无法推送,因为更新被拒绝,因为远程包含你本地没有的工作。



但是我不能拉



git pull RemoteName master //拒绝合并不相关的历史记录



所以我尝试 fetch merge 以便使用 - allow -unrelated-history 与合并建议的地方,但由于不明白如何合并真正工作,而诅咒我没有在第1章后红色git手册失败:)

认真如何从这里开始?



git fetch RemoteName // Ok

git merge RemoteName //对于当前分支没有远程控制。
git merge RemoteName master // merge:RemoteName - 不是我们可以合并的东西

解决方案

你有两个不相关的项目。一个在github上,另一个在你的硬盘上,因为你只通过没有git命令的web浏览器复制文件。试试这个 - 将您的项目备份到hdd到另一个目录,然后从目录中删除您想要与github同步的项目。然后在你的目录下写命令 git clone your_link_from_github 。该项目从github下载到您的硬盘并且将被同步。



你可以找到关于git命令的很好的备忘单这里


I have a folder with VS Solution with few projects and so on. I've created a GitHub repository and uploaded the contents of that directory via the web interface. Now, changes have been made to my projects, and I want to start pushing those to my github repository. So I use git init, than stage and commit files.

But I can't push because "Updates were rejected because the remote contains work that you do not have locally."

But I can't pull either because

git pull RemoteName master // refusing to merge unrelated histories

So I try to fetch and merge in order to use --allow-unrelated-histories with merge as suggested somewhere, but fail miserably because of not understanding how merge really works while cursing I didn't red git manual after chapter 1 :)

Seriously how to proceed from here?

git fetch RemoteName //Ok

git merge RemoteName //No remote for the current branch.
git merge RemoteName master //merge: RemoteName - not something we can merge

解决方案

You have two unrelated projects. One on github and second on your hdd, because you copied files only via web browser without git commands. Try this - backup your project on hdd to another directory and then delete project from directory, which you want to synchronize with github. Then in your directory write command git clone your_link_from_github. The project downloads from github to your hdd and will be synchronized.

You can find nice cheat sheet about git commands here.

这篇关于从git init开始,Git推送到远程仓库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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