git 的新手:git 推送错误
new to git : git push giving errors
我是 GIT 的新手,在尝试了很多东西后发布了这个。
问题很简单:我在 master 中有一个文件 'A',它也存在于其他分支 'test' 中。在这两个文件中,都有变化,我必须合并这些变化
我知道有很多早期的帖子,社区可以指导我,但我有一个我无法解决的具体问题:
所以这是我尝试过的事情
- 我当前的分支是分支 'test' 并且本地系统上的文件(在 git 目录中)显示了从那个 branch.Now 的变化我必须合并来自 master 的变化所以我切换了掌握使用git结帐命令
- 然后,使用 git pull origin master 和 Git 合并测试,因为我必须将更改从 master 合并到 'test' 分支。尝试时,这两个命令都显示文件 'A' 中存在冲突(例如错误:由于未合并文件而无法合并。自动合并失败等....)
- 然后,搜索这些错误,许多帖子建议我必须使用 kdiff 等工具手动合并文件。
现在我的问题出现了:
我可以轻松地复制主分支中 Git 集线器(存储库)中的更改,并更新 git 本地存储库中的文件(其版本是分支 'test')。我的问题是:git 如何知道合并已完成?我什至又做了一次 运行 命令 'git push origin master' 但可以理解,它说失败了,当前分支的提示落后了....等....
我什至想,因为我的本地 git 存储库现在已经更新和最终更改(在手动复制更改之后)让我使用 git push -f origin master 进行强制更新(我知道,它不应该是合并此类更改的首选方式)。尽管此命令 运行 正常,但执行 'git checkout master' 时抛出另一个错误,提示文件 'A' 需要合并 - 您需要先解析当前索引' .
这让我认为 Git 不知道合并已经发生,这让我明白了 git 如何知道我手动合并了更改???
另一件事 pn 同样的问题,我知道不知何故,我必须将本地 Git 存储库(属于分支测试)中的文件 A 与其存储库中 master 中存在的版本进行比较。
问题:如何在本地并排获取两个文件以进行比较?
我知道应该以某种方式完成,这样 GIT 也知道合并已完成并且本地计算机中存在的文件已更新合并更改并准备好推送到主机
我知道这可能是我遗漏的一件愚蠢的事情,但经过大量搜索后真的找不到任何东西
============================================= =
编辑:根据少数成员的要求添加实际命令..谢谢!
2000@LTDLUK3400 MINGW64 /d/GitAll/LearnGit (newGitBranch)
$ git checkout master
Switched to branch 'master'
Your branch is ahead of 'origin/master' by 1 commit.
(use "git push" to publish your local commits)
2000@LTDLUK3400 MINGW64 /d/GitAll/LearnGit (master)
$ git pull origin master
remote: Counting objects: 3, done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), done.
From https://github.com/apexkeen/LearnGit
* branch master -> FETCH_HEAD
8682a7a..bed8390 master -> origin/master
Auto-merging Readme.txt
CONFLICT (content): Merge conflict in Readme.txt
Automatic merge failed; fix conflicts and then commit the result.
2000@LTDLUK3400 MINGW64 /d/GitAll/LearnGit (master|MERGING)
$ git merge newGitBranch
error: merge is not possible because you have unmerged files.
hint: Fix them up in the work tree, and then use 'git add/rm <file>'
hint: as appropriate to mark resolution and make a commit.
fatal: Exiting because of an unresolved conflict.
2000@LTDLUK3400 MINGW64 /d/GitAll/LearnGit (master|MERGING)
$ git config --global --edit
2000@LTDLUK3400 MINGW64 /d/GitAll/LearnGit (master|MERGING)
$ git push origin master
To https://github.com/apexkeen/LearnGit.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/apexkeen/LearnGit.git'
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.
2000@LTDLUK3400 MINGW64 /d/GitAll/LearnGit (master|MERGING)
$ git push -f origin master
Total 0 (delta 0), reused 0 (delta 0)
To https://github.com/apexkeen/LearnGit.git
+ bed8390...674678e master -> master (forced update)
2000@LTDLUK3400 MINGW64 /d/GitAll/LearnGit (master|MERGING)
$ git checkout master
Readme.txt: needs merge
error: you need to resolve your current index first
- 在测试分支中提交代码。
- 结帐到 master 并执行 git pull origin master,确保您的 master 与存储库保持最新。
- 结帐以测试分支并进行变基。
- git rebase master,如果没有任何冲突就可以了,否则手动解决特定文件中的冲突。
- 解决冲突后做git rebase --continue
- 之后 git 添加 。 & git 提交。
- 你现在已经准备就绪,你将拥有来自 master 和 test 分支的所有更改。
当 git 告诉您冲突已经发生时,您需要解决冲突。
2000@LTDLUK3400 MINGW64 /d/GitAll/LearnGit (master)
$ git pull origin master
remote: Counting objects: 3, done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), done.
From https://github.com/apexkeen/LearnGit
* branch master -> FETCH_HEAD
8682a7a..bed8390 master -> origin/master
Auto-merging Readme.txt
CONFLICT (content): Merge conflict in Readme.txt
Automatic merge failed; fix conflicts and then commit the result.
此时需要运行git mergetool
修复readme文件中的冲突。一旦你的文件看起来像它应该的样子,你可以 运行 git commit
它会用一些关于合并和冲突的信息预先填充提交消息。届时,您将能够 git push
您对 origin 的更改。
按照目前的情况,您随后尝试做其他事情,但这是开始出错的地方,因为您必须首先解决冲突(如其输出中所述的命令)。
稍后您将 git push
与 -f
标志一起使用,这导致远程更改丢失。这在非学习环境中应该避免!
值得广泛使用 git status
来查看您的工作副本在任何给定时间发生的情况。
我是 GIT 的新手,在尝试了很多东西后发布了这个。
问题很简单:我在 master 中有一个文件 'A',它也存在于其他分支 'test' 中。在这两个文件中,都有变化,我必须合并这些变化
我知道有很多早期的帖子,社区可以指导我,但我有一个我无法解决的具体问题:
所以这是我尝试过的事情
- 我当前的分支是分支 'test' 并且本地系统上的文件(在 git 目录中)显示了从那个 branch.Now 的变化我必须合并来自 master 的变化所以我切换了掌握使用git结帐命令
- 然后,使用 git pull origin master 和 Git 合并测试,因为我必须将更改从 master 合并到 'test' 分支。尝试时,这两个命令都显示文件 'A' 中存在冲突(例如错误:由于未合并文件而无法合并。自动合并失败等....)
- 然后,搜索这些错误,许多帖子建议我必须使用 kdiff 等工具手动合并文件。
现在我的问题出现了:
我可以轻松地复制主分支中 Git 集线器(存储库)中的更改,并更新 git 本地存储库中的文件(其版本是分支 'test')。我的问题是:git 如何知道合并已完成?我什至又做了一次 运行 命令 'git push origin master' 但可以理解,它说失败了,当前分支的提示落后了....等....
我什至想,因为我的本地 git 存储库现在已经更新和最终更改(在手动复制更改之后)让我使用 git push -f origin master 进行强制更新(我知道,它不应该是合并此类更改的首选方式)。尽管此命令 运行 正常,但执行 'git checkout master' 时抛出另一个错误,提示文件 'A' 需要合并 - 您需要先解析当前索引' .
这让我认为 Git 不知道合并已经发生,这让我明白了 git 如何知道我手动合并了更改???
另一件事 pn 同样的问题,我知道不知何故,我必须将本地 Git 存储库(属于分支测试)中的文件 A 与其存储库中 master 中存在的版本进行比较。 问题:如何在本地并排获取两个文件以进行比较?
我知道应该以某种方式完成,这样 GIT 也知道合并已完成并且本地计算机中存在的文件已更新合并更改并准备好推送到主机
我知道这可能是我遗漏的一件愚蠢的事情,但经过大量搜索后真的找不到任何东西
============================================= =
编辑:根据少数成员的要求添加实际命令..谢谢!
2000@LTDLUK3400 MINGW64 /d/GitAll/LearnGit (newGitBranch)
$ git checkout master
Switched to branch 'master'
Your branch is ahead of 'origin/master' by 1 commit.
(use "git push" to publish your local commits)
2000@LTDLUK3400 MINGW64 /d/GitAll/LearnGit (master)
$ git pull origin master
remote: Counting objects: 3, done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), done.
From https://github.com/apexkeen/LearnGit
* branch master -> FETCH_HEAD
8682a7a..bed8390 master -> origin/master
Auto-merging Readme.txt
CONFLICT (content): Merge conflict in Readme.txt
Automatic merge failed; fix conflicts and then commit the result.
2000@LTDLUK3400 MINGW64 /d/GitAll/LearnGit (master|MERGING)
$ git merge newGitBranch
error: merge is not possible because you have unmerged files.
hint: Fix them up in the work tree, and then use 'git add/rm <file>'
hint: as appropriate to mark resolution and make a commit.
fatal: Exiting because of an unresolved conflict.
2000@LTDLUK3400 MINGW64 /d/GitAll/LearnGit (master|MERGING)
$ git config --global --edit
2000@LTDLUK3400 MINGW64 /d/GitAll/LearnGit (master|MERGING)
$ git push origin master
To https://github.com/apexkeen/LearnGit.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/apexkeen/LearnGit.git'
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.
2000@LTDLUK3400 MINGW64 /d/GitAll/LearnGit (master|MERGING)
$ git push -f origin master
Total 0 (delta 0), reused 0 (delta 0)
To https://github.com/apexkeen/LearnGit.git
+ bed8390...674678e master -> master (forced update)
2000@LTDLUK3400 MINGW64 /d/GitAll/LearnGit (master|MERGING)
$ git checkout master
Readme.txt: needs merge
error: you need to resolve your current index first
- 在测试分支中提交代码。
- 结帐到 master 并执行 git pull origin master,确保您的 master 与存储库保持最新。
- 结帐以测试分支并进行变基。
- git rebase master,如果没有任何冲突就可以了,否则手动解决特定文件中的冲突。
- 解决冲突后做git rebase --continue
- 之后 git 添加 。 & git 提交。
- 你现在已经准备就绪,你将拥有来自 master 和 test 分支的所有更改。
当 git 告诉您冲突已经发生时,您需要解决冲突。
2000@LTDLUK3400 MINGW64 /d/GitAll/LearnGit (master)
$ git pull origin master
remote: Counting objects: 3, done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), done.
From https://github.com/apexkeen/LearnGit
* branch master -> FETCH_HEAD
8682a7a..bed8390 master -> origin/master
Auto-merging Readme.txt
CONFLICT (content): Merge conflict in Readme.txt
Automatic merge failed; fix conflicts and then commit the result.
此时需要运行git mergetool
修复readme文件中的冲突。一旦你的文件看起来像它应该的样子,你可以 运行 git commit
它会用一些关于合并和冲突的信息预先填充提交消息。届时,您将能够 git push
您对 origin 的更改。
按照目前的情况,您随后尝试做其他事情,但这是开始出错的地方,因为您必须首先解决冲突(如其输出中所述的命令)。
稍后您将 git push
与 -f
标志一起使用,这导致远程更改丢失。这在非学习环境中应该避免!
值得广泛使用 git status
来查看您的工作副本在任何给定时间发生的情况。