请记住,我对Git完全陌生,对术语不太了解
我有一个分支,reference-redo在一个GitHub存储库和一个不同的(非git)文件夹,我想用它来替换reference-redo分支的内容。
打开Git bash中的文件夹:
git init:添加一个.git文件夹(表示它初始化了一个空的Git存储库)
git add .:添加所有文件和文件夹(警告LF被CR替换,但没有错误)
git commit -m 'Fixed usage of references for ObjectPointer type':“创建模式.”14份文件
git remote add origin https://github.com/me/repo-name.git:没有输出,也没有错误
git checkout -b reference-redo:切换到新的分支“引用-重做”
git remote -v
git push origin reference-redo
! [rejected] reference-redo -> reference-redo (fetch first)
error: failed to push some refs to 'https://github.com/me/repo-name.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.这似乎是因为我正在替换分支的文件,而不是更新它。我将不得不推送到一个新的分支,还是我可以推送这个当前目录?
运行git remote show origin显示分支确实存在:
Remote branches:
functions new (next fetch will store in remotes/origin)
master new (next fetch will store in remotes/origin)
reference-redo new (next fetch will store in remotes/origin)
Local refs configured for 'git push':
master pushes to master (local out of date)
reference-redo pushes to reference-redo (local out of date)发布于 2020-10-10 19:18:11
如果要在该分支中覆盖整个历史记录,可以使用git push --force。
否则,通过删除和复制本地文件管理器中的文件并像其他时间一样提交文件,定期进行更新。
https://stackoverflow.com/questions/64296410
复制相似问题