Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"selectively" merging with git

Tags:

git

I'd like to have a git repository with a branch for development and a branch for deployment. I have several configuration and database files that my project needs. I want the deployment branch not to have any configuration or database files for my project, but I want to keep versions of those files in my development branch in order to be able to test. Is there any way, when merging the development branch into the deployment branch, to have the merge process ignore those files?

like image 340
Rex Avatar asked Jun 19 '11 22:06

Rex


People also ask

How can I selectively merge or pick changes from another branch in git?

Roughly speaking, you use git rebase -i to get the original commit to edit, then git reset HEAD^ to selectively revert changes, then git commit to commit that bit as a new commit in the history.

Can I merge specific commit?

The Usage of Git Merge The git merge command is targeted at combining two branches. You can also use it for merging several commits into a single history. The merge commits involve two parent commits.

Can you merge just one file in git?

In Conclusion. We can use git checkout for far more than simply changing branches. If we supply it with a branch name and a file, we can replace a corrupted or broken file. Instead, if we want to pass some of the changed content we can use the --patch flag to manually merge an individual file.

How do I merge specific branches?

To merge branches locally, use git checkout to switch to the branch you want to merge into. This branch is typically the main branch. Next, use git merge and specify the name of the other branch to bring into this branch. This example merges the jeff/feature1 branch into the main branch.


1 Answers

You could use git merge --no-commit and delete the config files before committing the merge. There might be more streamlined possibilities, though.

However, I'd recommend either having the files in both branches or not having them at all. What language and development environment are you using? Do they offer some possibility for specifying different files depending on what kind of build you are trying to make?

like image 92
Aasmund Eldhuset Avatar answered Sep 18 '22 17:09

Aasmund Eldhuset