user3220745
user3220745

Reputation: 98

Merge Certain Files (not commits) From One Branch to Another Branch

I have logged countless hours trying to solve this issue. I have found many similar questions, but, have not found an answer that I can understand as addressing the problem. Here is my problem that I hope you can help with:

I have a project that has a deploy branch (with only the script and its config file) that I push to github so my customer can pull the latest release of code. I have a development branch that has those same 2 files, the script and config file, plus many other files (sometimes hundreds and some of them really 50 to 200 MB). Let's call these branches 'project' and 'project-dev'. The files in the dev branch get populated, added, and committed during the course of coding.

I have a .gitignore in the script directory of the project branch that ignores everything put itself and the files I listed above.

.gitignore in my script dir:

*
!.gitignore
!/*.pl
!/*.conf

So, when I am not coding and do my last commit to project-dev, I do this:

git checkout project

git merge project-dev

And git merges every file from project-dev into project. But wait, I have .gitignore file int he script directory... No problem one merge's first tasks delete the .gitignore file :(

delete mode 100644 scripts/.gitignore

And then all the other files get added... :(

create mode 100644 scripts/0.0.0.0-nets.txt
create mode 100644 scripts/1453134549-all-exported-networks.csv
create mode 100644 scripts/1453392277-all-hosts.csv
create mode 100644 scripts/1453392277-all-networks.csv
create mode 100644 scripts/1453407843-all-hosts.csv
create mode 100644 scripts/1453407843-all-networks.csv
create mode 100644 scripts/1453409789-all-hosts.csv
create mode 100644 scripts/1453409789-all-networks.csv
create mode 100644 scripts/1453415039-all-hosts.csv
create mode 100644 scripts/1453415039-all-networks.csv
create mode 100644 scripts/1453428006-all-hosts.csv
create mode 100644 scripts/1453428006-all-networks.csv
create mode 100644 scripts/1453429183-all-hosts.csv
create mode 100644 scripts/1453429183-all-networks.csv
create mode 100644 scripts/1453432643-all-hosts.csv
create mode 100644 scripts/1453432643-all-networks.csv
create mode 100644 scripts/1453433494-all-hosts.csv
create mode 100644 scripts/1453433494-all-networks.csv
create mode 100644 scripts/1453437439-all-hosts.csv
.
.
.
create mode 100644 scripts/Report_NETS_20160122_103537.txt
create mode 100644 scripts/Report_NETS_20160122_103537.txt
create mode 100644 scripts/Report_NETS_20160122_105113.txt
create mode 100644 scripts/Report_NETS_20160122_105113.txt
create mode 100644 scripts/Report_NETS_20160122_153820.txt
create mode 100644 scripts/Report_NETS_20160122_153820.txt
create mode 100644 scripts/Report_NETS_20160122_155209.txt
create mode 100644 scripts/Report_NETS_20160122_155209.txt
create mode 100644 scripts/all-hosts.dat
create mode 100644 scripts/all-nets.dat
create mode 100644 scripts/exported-networks-headers.csv
create mode 100644 scripts/fixed.csv
create mode 100644 scripts/hosts.csv
create mode 100644 scripts/network-report-headers-some-commented.txt
create mode 100644 scripts/network-report-headers.txt
create mode 100644 scripts/networks-headers.csv
create mode 100644 scripts/networks.csv
create mode 100644 scripts/refactored.txt
create mode 100644 scripts/test-host.csv
create mode 100644 scripts/test-network.csv

There are really only 2 files that I want, a script and its config to come over during the merge (which may not be in the output above because they are in the middle of a really long file listed...). And no, there is not 'commit' that can single out the files. When I update the script and run it, it creates a bunch of files, all of which is in the commit that I create when I decide things are working OK.

I want / need all these working files in the -dev branch, but, cannot have them in the projection customer facing branch.

Is there a way? Or, am I out of luck if I do not have a one to one relationship between a file and a commit?

Thanks in advance!

acc...

Upvotes: 0

Views: 65

Answers (1)

nge
nge

Reputation: 116

Have you tried this:

git checkout 'project'

git checkout 'project-dev' script_file_name

git checkout 'project-dev' config_file_name

It should get those 2 files from your 'project-dev' branch into your project branch.

Upvotes: 1

Related Questions