Question

I've started using git recently for a Django web app. I am also using the South Migration app for Django.

I have 2 branches - develop and master. I added new features to develop and now I would like to merge develop into master.

The problem is I have migration folders and I don't want them to be merge. For that reason, I added a .gitignore file in the main folder of the master branch and the develop branch.

.gitignore:

*.pyc
!/.gitignore
acpkinballmanageevents/migrations/
acpkinballmanageleague/migrations/
acpkinballmanagemembers/migrations/
acpkinballmanageteams/migrations/
blog/migrations/
managelayerslider/migrations/
managesite/migrations/

But it asks me to merge some .pyc file and files in the /migrations/ folders....

Is it possible to not merge them or is it recommended to merge the migration files?

EDIT:

Here is my .gitattributes file:

acpkinballmanageevents/migrations/* merge=ours
acpkinballmanageleague/migrations/* merge=ours
acpkinballmanagemembers/migrations/* merge=ours
acpkinballmanageteams/migrations/* merge=ours
blog/migrations/* merge=ours
managelayerslider/migrations/* merge=ours
managesite/migrations/* merge=ours
Was it helpful?

Solution

If you have these files previously tracked in git, they are already recorded in git’s view of the branch content. Git still knows about the files and will ask you to merge, even if you try and ignore them.

You could have the files forcefully ignored - see Ignore files that have already been committed to a Git repository and specifically this answer on how to use git ls-files to have all the files that match your newly introduced .gitignore excluded automatically.

Alternatively, and what seems to me like the better approach in your case – you could use git attributes to describe specific merge strategies for the files. See http://git-scm.com/book/en/Customizing-Git-Git-Attributes#Merge-Strategies

You don’t want to merge the migration files from develop to master, say, you can setup an attribute file like this (under master):

----- migration/.gitattributes ----
* merge=ours
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top