git - 让本地仓库与远程同步
问题描述
我正在尝试将本地项目同步到现有的远程仓库。
从我的本地文件夹
git init
git remote add origin
git fetch
问题是遥控器已经发散了,所以它提前了 2 或 3 次提交
我跑了
git status
并得到
On branch master
No commits yet
Untracked files:
(use "git add <file>..." to include in what will be committed)
我需要将本地与远程同步。如果我跑
git pull origin master
我会收到一个错误:您对以下文件的本地更改将被合并覆盖。请提交您的更改或存储它们。我将无法存储,因为我没有初始提交。
如何跟踪文件并执行拉取请求以使本地存储库与远程同步?
更新 这是通过运行解决的
git fetch --all
git reset --hard origin/masater
解决方案
按着这些次序
- 首先存储本地更改
git stash
- 然后拉动回购
git pull origin master
- 然后弹出隐藏
git stash pop
- 然后使用
git add .
- 然后提交并推送到master
推荐阅读
- java - 如何根据构造函数中设置的 ID 返回某个对象?
- python - 将多个没有类名的html标签解析为不同的变量
- c - 分叉程序请查看
- python - python pandas:为什么我不能在同一个 read_csv 语句中同时使用 index_col 和 usecols ?升值错误
- android - 如何在不要求用户第一次在浏览器或应用程序之间进行选择的情况下从链接打开 Android 应用程序
- python - 具有交叉验证的卷积神经网络
- java - 寻找一种不包含一系列随机数重复的方法
- azure-data-factory-2 - 在区域 Azure 中断期间,我的共享自托管集成运行时是否可用于其他 Azure 数据工厂?
- ios - 在 Combine 中处理发布者中的错误的最佳做法是什么?(从 CoreLocation 发布标题更新)
- javascript - 将 AWS MySQL 查询的 JSON 输出并在网页上显示为 DataTable