首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将分支中的所有文件和文件夹替换为(当前)非git文件夹。

将分支中的所有文件和文件夹替换为(当前)非git文件夹。
EN

Stack Overflow用户
提问于 2020-10-10 17:38:59
回答 1查看 870关注 0票数 0

请记住,我对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

代码语言:javascript
复制
 ! [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显示分支确实存在:

代码语言:javascript
复制
  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)

吉特推

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-10-10 19:18:11

如果要在该分支中覆盖整个历史记录,可以使用git push --force

否则,通过删除和复制本地文件管理器中的文件并像其他时间一样提交文件,定期进行更新。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64296410

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档