git-merge

How to force consistent line endings in Git commits with cross-platform compatibility

时光怂恿深爱的人放手 提交于 2020-01-21 19:39:50
问题 I am having issues with merge conflicts due to line endings while working with someone who uses a different OS. I work on Windows and my colleague is on Mac. When he pushes his changes, sometimes files he hasn't worked on show up in the diff as being changed, because the line endings now show ^M on each file. This has lead to merge conflicts. I read in the Git docs the following: Git can handle this by auto-converting CRLF line endings into LF when you add a file to the index, and vice versa

How to resolve git merge conflict, from command line, using a given strategy, for just one file?

泄露秘密 提交于 2020-01-20 04:33:06
问题 Let's say I did a git merge and have a conflict in some file, say package.json or pom.xml , and perhaps some other files. I would like to automatically resolve merge conflicts for certain files from command line, while letting myself resolve manually all the other conflicts, if any, and making sure I don't lose valuable changes from any branch. Because of 2), I can't use git merge -Xours as this would resolve all conflicts. I want to resolve only conflicts in one particular file. Because of 3

git pull always fails, but git fetch/merge are fine

邮差的信 提交于 2020-01-17 03:59:21
问题 When I git pull in any repository, I always get the following merge error: aetherboard:shwangster shwangster$ git pull -v From github.com:sirspinach/shwangster = [up to date] master -> origin/master merge: 012012012012012012012012012012012012012012012012012012012012 - not something we can merge On the other hand, git fetch and git merge origin/master work like a charm. So I've been able to work around this problem for a while. However, I needed to update brew today, and the same error

Why doesn't git merge changes when two branches are different but with no new commits in either branch?

风格不统一 提交于 2020-01-14 09:01:31
问题 For example, I my master branch has stuff in it. Another branch called other_branch has stuff+more_stuff in it. Each branch has nothing to commit. If I checkout master then try to merge other_branch, git says "Already up-to-date." and nothing happend. why won't more_stuff be merged into master in this case? Is that how git was designed? NOTE: other_branch was created from an older commit of master. 回答1: It's very simple. If git says "Already up-to-date" it means the branches have not diverged

Git merge deleting code that should stay

℡╲_俬逩灬. 提交于 2020-01-14 03:41:06
问题 When merging branches, Git automatically removes code that shouldn't be removed. Basically we have two main branches: MASTER and DEVELOP. MASTER has our PRODUCTION code. DEVELOP has our current develop scenario. All new code starts in other branches, that usually refer to the issue or new feature. The problem happens when we try to merge this feature or hotfix branch into develop. Our daily activities is: (current branch develop): git pull origin develop git checkout -b some-feature. Both

On Github, merging PR into different branch

北慕城南 提交于 2020-01-14 01:57:51
问题 Say someone submits a PR to public/master on Github. Is there a way to merge that PR into a different branch? Otherwise, looks like I have to merge into public/master, then merge that backwards into a development/staging branch. It's like having people do a hotfix and then merging the hotfix into a development branch, which is something we normally should want to avoid right? Seems to make more sense to have people track and submit PRs to a staging/development branch instead of master. What

Git: How to convert an existing `merge` to a `merge --squash`?

為{幸葍}努か 提交于 2020-01-13 19:07:45
问题 I performed multiple merge commits but they should have been merge --squash instead. The conflict resolution took more than a day so I can't afford to redo the merging by hand. Is there a way to convert the merge to merge --squash ? 回答1: It's worth noting here that git merge and git merge --squash are closely related, but git merge --squash does not create a merge . The phrasing here is very important, particularly the article "a" in front of "merge": "a merge" is a noun, while "to merge" is

Git: How to convert an existing `merge` to a `merge --squash`?

强颜欢笑 提交于 2020-01-13 19:05:11
问题 I performed multiple merge commits but they should have been merge --squash instead. The conflict resolution took more than a day so I can't afford to redo the merging by hand. Is there a way to convert the merge to merge --squash ? 回答1: It's worth noting here that git merge and git merge --squash are closely related, but git merge --squash does not create a merge . The phrasing here is very important, particularly the article "a" in front of "merge": "a merge" is a noun, while "to merge" is

Git command to find what branches were merged into current branch and when

你离开我真会死。 提交于 2020-01-13 09:46:09
问题 I have several feature branches that are being automatically merged into the integration branch. I'd like to know if and when this is happening. I can type git log which will show me that a merge has happened but for some reason it does not show me from which feature branch it just says "merged integration_branch into integration_branch" I can type git branch --merged but that only lists the feature branches that are being merged into the integration branch. I'd like to know when and by whom,

Restore git files deleted after git merge --abort

 ̄綄美尐妖づ 提交于 2020-01-12 08:02:07
问题 I've lost files added to git during "merge conflict" phase. Step by step: git pull git status Git informs me about "merge conflict", that's okay. Then I create a new file and add it to git. vi test.txt git add test.txt After that, abort merge: git merge --abort I have not found the file "test.txt" neither in directory, nor via "git fsck", nor "git reflog". Is it possible to restore the file? 回答1: What have you tried with git fsck ? see this SO question : Recover files that were added to the