I'm trying merge my branches, but I get the error merge completed with conflict
http://prntscr.com/936x6n (as u see even with git gui i can't)
I tried skip database. So i added to .gitignore .mdf and .ldf, but still nothing. I can't merge branches. What should I do?
If you want to ignore some files during the merge, Git attributes using merge strategies for specific files could help. Here is an example that the specifies files stay at whatever version you originally had.
create .gitattributes in your repo and edit:
merge=ours
merge=ours
...
And then define a dummy ours merge strategy with:
$ git config --global merge.ours.driver true
Related
Please consider this scenario.
My trunk has files A.txt, B.txt, C.txt, all the way to... Z.txt.
Branch has files A.txt and C.txt which I modified.
When I merge branch to trunk, the result is modified A.txt, modified C.txt and all the other unmodified files like B.txt, D.txt, etc.
However, I would like to have the trunk only contain the modified A.txt and C.txt.
How can I do that. Please let me know.
Since TFS include both TFVC and Git as source control, not sure which one you are using.
If you are using TFVC:
When I merge branch to trunk, the result is modified A.txt, modified
C.txt and all the other unmodified files like B.txt, D.txt, etc.
This is the expected and by designed behavior, we will not be able to delete any files which only exist in target branch during merge process.
You have to manually delete those files in target branch after merge process.
If you are using Git:
Please kindly review this solution: Make the current Git branch a master branch & How to replace master branch in Git, entirely, from another branch?
I have a branch that has a different schema than my master. When I try to rebase with master, I get a merge conflict error with the schemas. I understand that this is happening because my schema on my branch is different than the one on my master. This is because I was working on something else in another branch and had to run migrations. I then merged that branch with my master. So now my master has a new table in the schema which the branch I am working on has no idea. So when I try to rebase with master it gives me a conflict error. Is there a way for the branch to automatically merge and take up the latest schema from the master when I rebase? I know there is a code snippet which I can put in my config file and call it in my attributes file, however, this solution does not seem to work for me since my migrations were made before I put that code in the config file.
If schema.rb (or any file for that matter) changed since you created your branch then you would have to manually merge the conflict.
Conflict happens only when file from both the branches have new changes present around same line numbers.
Doing below like mentioned in another answer would make you lose the changes done in your current branch:
git rebase -Xtheirs the_branch_name
In case of schema.rb generally the version number line throws the conflict. You should always put the higher number of two versions:
ActiveRecord::Schema.define(version: 2017081234567)
Delete the schema file, apply migrations if there are any at this stade of the rebase, dump the new rails schema and git rebase --continue. Repeat when necessary.
Since schema.rb is automatically generated after each migration, the simplest way to resolve conflict is to remove this file, run
rake db:drop db:create db:migrate
and commit the changes.
I have cloned my TFVC from VSTS and it pulled all my branches without any errors. I then followed a number of online posts that said to cleanup my projects by doing the following:
Remove the GlobalSection(TeamFundationVersionControl) section from solution files
remove all *.vssscc files
Remove all *.vspscc files
When I do this I get almost all of my files showing up in the Changes window under Team Explorer. All of these files have no changes when doing a diff except for the files discussed earlier.
What is the proper way to cleanup branches after doing the clone from TFVC to git?
Thanks
If you want to migrate an existing TFVC repos to Git repos, you can use the git-tfs tool, which allows you to migrate a TFVC repo to a Git repo in just a couple of commands.
In my example, with the commands below, I have successfully migrated an existing TFVC repo to Git repo with all branches.
If you don't want to clone the branches, you can specify --branches=VALUE (VALUE=none|auto|all), check https://github.com/git-tfs/git-tfs/blob/master/doc/commands/clone.md
When I do this I get almost all of my files showing up in the Changes window under Team Explorer. All of these files have no changes when doing a diff
That should be due to a bad end of line setting...
except for the files discussed earlier.
First commit them...
Then fix your setting.
You've got 2 options (not mutualy exclusive, you could do the 2. But if you do only one, do the 2nd) :
(old style), set the git core.autocrlf setting. On windows, that's either true to convert all file to a windows eol style or false to tell git to not touch the files. It's a matter of choice. This settings will be used for ALL your repositories but will be personal
(new one recommended) Add a .gitattributes files to telle git how to handle eol for all type of files. This settings will be used for this repository only but will be shared by all the developpers and noone won't be able to commit bad files.
Be aware that for all the strategies that you will try, to be sure that it works, you will have to do soemthing special. You will have to wipe all the files and checkout them all from the repository (because that's at this special moment that git modify the files):
git checkout .
There is a possibility that in fact, the files are modified because they have been checkouted in the format you wish, so commmit them all (you will be obliged) and apply the eol strategy, just after...
A good doc on the subject that you should read carefully and understand before trying something...
PS: handling end of line is not an easy task in a git repository and it will take you quite some time and you will have to try a lot of things before really understanding how it works ( I'm not pretty sure myself ;) )
I'm trying to push my Rails project to Heroku, but Git isn't allowing me to do anything at the moment. Here's what I've done so far:
git push heroku failed because the heroku branch was "ahead" of my local branch, which should not have been possible.
I pulled and there was a conflict with .idea/workspace.xml. I wasn't able to find out what that file is, but it's huge and Git wrote all kinds of garble to it. Too much to manually "resolve" conflicts.
I saw some stackoverflow posts talking about git-ignoring that file (maybe it's some IDE file for RubyMine or something?), so I tried to move the file away to avoid the conflict
I ran git add -A (also tried git add . and git add)
git commit --amend fails because "You are in the middle of a merge"
git merge --abort fails because "Untracked working tree file '.idea/workspace.xml' would be overwritten by merge (despite the fact that the file has been moved)
git reset --merge fails for the same reason.
How can I make Git work again?
.idea/workspace.xml
This file is your idea workspace files. They are generated by IntelliJ tools.
I saw some stackoverflow posts talking about git-ignoring that file (maybe it's some IDE file for RubyMine or something?), so I tried to move the file away to avoid the conflict
Simply add the folder to your .gitignore but since its already committed you will have to remove it from the repository:
# Quit the merge
git merge --abort
# remove the whole folder from the repo
git rm -rf --cached .idea/
# add it to the .gitignore: idea/
# add and commit your changes
git add .- A
git commit -m " Removed idea folder"
git push origin <branch>
If you still unable to do it?
First reset the code to the previous state and then do the above code again.
The reset will take you to your last commit before the pull
git commit -am "message" worked (as opposed to amending a commit)
I have resolved a similar problem by simply deleting the workspace.xml file. By building and running the program again idea will autogenerate a compatible file.
Doing a pull from master into my local branch on a shared ROR project. Git says:
branch master -> FETCH_HEAD error: Your local changes
to the following files would be overwritten by merge:
config/environments/development.rb Please, commit your changes or
stash them before you can merge. Aborting
development.rb is not showing up as having been modified, and, in fact, when I actually do modify it, it still doesn't show as having been modified. This is happening on all branches, effectively preventing me from merging in master.
I should say here that I am a designer on this project and my ROR and Git skills are not huge (I have mostly been using the Tower GUI for managing branches). However, I've been successfully contributing to the project for over a year and never came across this issue before.
If you type 'git status' do you see development.rb in the list of untracked files? If so you need to 'git add' it and commit.
Alternately, in the root of your project look at .gitignore and see if it's listed in there for some weird reason. It shouldn't be, but it's worth looking.
My gut feeling that you are using git update-index --assume-unchanged development.rb, but don't remember it. If it is the case, use --no-assume-unchanged then.
It is hard to say without looking at your .gitignore but you could have config/environments/development.rb in that file, in which case you wouldn't see changes.
But that isn't the real issue, it sounds like you just need to commit then pull. This is what I would do.
Add config/environments/development.rb to your commit, commit changes then pull. If that doesn't work, I would just delete your local copy and clone a new one.
I hope that helps.