git-merge

git diff to see what a merge would introduce

旧街凉风 提交于 2020-01-01 06:11:12
问题 So me and a friend have been working on a project. Most of the time merges are painless as we generally work in different areas. Recently we have been running into eachother more and more creating nasty merges (deadlines). So we began investigating ways to see what a merge would do. I found a way to use git diff: git diff mybranch...hisbranch This gives pretty good results. The problem is, since that it uses the last common ancestor, and that ancestor is getting farther and farther back there

Git refusing to merge because of changes to an unchanged file

那年仲夏 提交于 2020-01-01 04:57:16
问题 I'm having a git problem where I want to merge a branch into master but it's refusing to merge because it thinks I have local changes to a file. Doing status shows no changes and diffing the files produces nothing. Here's the terminal output: $ git checkout ProductsAndContents Switched to branch 'ProductsAndContents' $ git status # On branch ProductsAndContents nothing to commit (working directory clean) $ git checkout master Switched to branch 'master' $ git status # On branch master nothing

How to undo a git merge squash?

允我心安 提交于 2020-01-01 04:16:07
问题 I have just done a git merge --squash feature-branch into my develop branch. The problem is that the above command updated the head without creating a new commit. My intention was to create one single commit to apply to the head of develop . So in short, the log for the develop branch before and after the merge are exactly the same. Is there a way to revert back develop to what it was before the git merge ? Thank you. Solution Based on the comment from Dan D. and the accepted answer below I

To git checkout without overwriting data

给你一囗甜甜゛ 提交于 2019-12-31 09:09:32
问题 How can you git-checkout without overwriting the data? I run git checkout master I get error: Entry 'forms/answer.php' would be overwritten by merge. Cannot merge. This is surprising, since I did not know that Git merges when I git-checkout . I have always run after the command separately git merge new-feature . This seems to be apparently unnecessary if Git merges at checkout. 回答1: Git is warning you that forms/answers.php has changes in your working copy or index that have not been

How to re-merge a file in the git?

匆匆过客 提交于 2019-12-30 00:14:06
问题 I have 10 files which have conflicts when merging branches. I've resolved all conflicts of the 10 files(took long time). Unfortunately before the commit, I find out that one file has been merged wrong and need start again for this file. :( in the Git, How to mark the file which has been merged unmerged, in other word, how to re-merge that one file? 回答1: git checkout -m <filename> This will remove it from the index, and revert back to a "conflicted" file that has all of the markers required to

How to determine if Git merge is in process

假装没事ソ 提交于 2019-12-29 05:09:08
问题 Is there a Git command that can be used to determine if a merge is in-process (i.e. uncommitted)? I know I can simply check for .git/MERGE_HEAD , but is this proper and/or future-proof for command-line scripts? 回答1: One trick is to use a Git command that will fail if a merge is in progress. You can then check the return code of the command. You'll also want to make sure that the command will not affect your working copy or index in the event that it succeeds. While there are many commands

Which version of the git file will be finally used: LOCAL, BASE or REMOTE?

大憨熊 提交于 2019-12-28 01:39:14
问题 When there's a collison during git merge , I open a mergetool called Meld. It opens three files LOCAL, BASE and REMOTE. As I've read LOCAL is my local branch, BASE is common ancestor and REMOTE is the branch to be merged. Now to my question: which version of the file will be finally used? Is it REMOTE? If so, can I edit it as I want, regardless what's in the BASE branch for example? 回答1: It's the one in the middle : BASE . In fact, BASE is not the common ancestor, but the half-finished merge

tell git to use ours merge strategy on specific files

Deadly 提交于 2019-12-27 19:13:29
问题 I have the following directory structure: /.git /.git/info/attributes /MyProject /MyProject/pom.xml /MyProject/MyCode.java I have branch master and bugfix. On both branches pom.xml and MyCode.java were modified. i would like to merge changes from bugfix to master only for MyCode.java and keep master version of pom.xml file. So I added "/.git/info/attributes" because i don't want to commit .gitattributes with the project $cat .git/info/attributes pom.xml merge=ours $git status # On branch

tell git to use ours merge strategy on specific files

。_饼干妹妹 提交于 2019-12-27 19:13:23
问题 I have the following directory structure: /.git /.git/info/attributes /MyProject /MyProject/pom.xml /MyProject/MyCode.java I have branch master and bugfix. On both branches pom.xml and MyCode.java were modified. i would like to merge changes from bugfix to master only for MyCode.java and keep master version of pom.xml file. So I added "/.git/info/attributes" because i don't want to commit .gitattributes with the project $cat .git/info/attributes pom.xml merge=ours $git status # On branch

How to resolve git error: “Updates were rejected because the tip of your current branch is behind”

百般思念 提交于 2019-12-27 19:12:08
问题 I recently started using Git (previously I used subversion but I am now doing some collaborative work on a project that uses bitbucket and git). All has been going well up until today when I find a well meaning colleague has pushed changes to the Master instead of making a branch. This means that when I try to commit I get the error: Updates were rejected because the tip of your current branch is behind I know this should be resolved by making a pull request to re-sync things but I don't want