Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
253 views
in Technique[技术] by (71.8m points)

github - Git push to remote repository started with git init

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...