我刚刚创建了一个新项目,并在其中添加了一些文件。 然后,我创建了一个新的GitHub存储库(公共)。
现在,我想将本地Git项目推送到远程GitHub。
所以我这样做:
git init
git add .
git commit -m "First commit"
然后:
git remote add https://github.com/user/project.git
git remote -v
# origin https://github.com/user/project (fetch)
# origin https://github.com/user/project (push)
然后我要推送新的项目:
git push
# fatal: The current branch master has no upstream branch.
# To push the current branch and set the remote as upstream, use
# git push --set-upstream origin master
所以我正在做的事情:
git push --set-upstream origin master
And get back:
# To https://github.com/user/project
# ! [rejected] master -> master (non-fast-forward)
# error: failed to push some refs to 'https://github.com/user/project'
# hint: Updates were rejected because the tip of your current branch is # behind
# hint: its remote counterpart. Integrate the remote changes (e.g.
# hint: 'git pull ...') before pushing again.
# hint: See the 'Note about fast-forwards' in 'git push --help' for details.
所以我一直遵循他们的指示:
git pull
And I get:
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.
git pull <remote> <branch>
If you wish to set tracking information for this branch you can do so with:
git branch --set-upstream-to=origin/<branch> master
并继续做他们写的事情:
git pull origin master
And get back:
From https://github.com/user/project
* branch master -> FETCH_HEAD
fatal: refusing to merge unrelated histories
我已经设法通过使用
来使其工作git clone https://github.com/user/project
但是我不认为这是正确的工作方式,是吗?
希望获得一些提示。 谢谢。
答案 0 :(得分:1)
您应该运行此命令,
git remote add origin https://github.com/user/project.git
不是
git remote add https://github.com/user/project.git
答案 1 :(得分:1)
我个人如下进行操作。我没有在计算机上运行executable -v -i <(<<<${inputData}) -o outputFile.eps
来创建项目:
在Github上创建存储库
克隆
将获取的git
文件夹(以及可选的.git
和README
文件)移动到工作文件夹
然后您就可以准备使用.gitignore
,add
,commit
。