0

Each time I come across something harder than pull and push with git, I end up fighting doing weird stuff that I could have done probably in one command if I was good at git.

This time I know for sure I am going to reuse the process a lot and I don't want to do it the wrong/long way. So I seek for a git expert to tell me how he would do that. Plus that look like something a lot of people must have wanted to do already.

I have a project on github, and I would like to organize it like that:

1: dev branch

The dev branch contains up to date code, and superfluous stuff used for continuous interrogation, benchmark creation folders, doc creation softwares...

2: master branch

The master would be a branch that reflects only version changes in the history (ie, each time I reach stable step on dev), without the superfluous files used in dev.

3: why

This organization allows master to be an the easy dowloadable point for every stable version of dev, with the addition of having a clear changelog, while the dev branch contains a regular low level technical changes commit history. I think it's really handy.

So I need a way to pull only some folders of the dev branch from master, but without leaving any trace in the history. Then I need to modify some files (version and readme), commit the result with a version changelog message as the message, and finally push to master.

What is the best way to do that according to people versatile in git?

Edit:

It would also resolve my problem if I could pull without pulling any unstaged file. This would allow me to configure as wanted master once and just pull with this option for every release.

Edit: Doing: git checkout dev -- LISTOFSTUFFIWANT work. But I dont find any way to ask git to "checkout everything from this branch except those 3 files"?

mike
  • 1,233
  • 1
  • 15
  • 36
ninjaconcombre
  • 456
  • 4
  • 15
  • 1
    Does this answer your question? [Applying the changes from branch b to a, without merging or adding commits](https://stackoverflow.com/questions/20045946/applying-the-changes-from-branch-b-to-a-without-merging-or-adding-commits) – mkrieger1 Jun 11 '20 at 15:27
  • Or maybe https://stackoverflow.com/questions/449541/how-to-selectively-merge-or-pick-changes-from-another-branch-in-git – mkrieger1 Jun 11 '20 at 15:28
  • Or maybe https://stackoverflow.com/questions/10784523/how-do-i-merge-changes-to-a-single-file-rather-than-merging-commits – mkrieger1 Jun 11 '20 at 15:30
  • When developing your workflow, I'd suggest reading up on established git workflows, if you haven't done this already. There are several in widespread use, meaning others have found them helpful. Once you read and understand them, you may want to use one, or still make up your own, with ideas gleaned from widely-used ones. – Basya Jun 11 '20 at 15:31
  • From the three links you provided @mkrieger, the best solution I am able to see is to use git checkout . If file paths can be a list of folders. The others solutions apply merge on either the whole branch, or on commits, or I can not understand them ;p. – ninjaconcombre Jun 11 '20 at 18:17
  • I checked https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow after what you said @Basya. They seem to take as hypothesis than all the branch have se same set of files. I am going to try to look for more tutorial like that to see if I come across a specific solution for my problem. Maybe the checkout solution is the best. Still waiting for someone to tell me why it is bad. – ninjaconcombre Jun 11 '20 at 18:19
  • The checkout solution would be to write a "release script" that go to master and checkout every intersting path from dev. – ninjaconcombre Jun 11 '20 at 18:27
  • That is a good tutorial; I think I started there. I am not sure why you say "They seem to take as hypothesis than all the branch have se same set of files.". Git allows you to add or delete or move files; different commits may have differences in the files they contain. – Basya Jun 11 '20 at 18:30
  • 1
    I'm also not sure why it bothers you to have all the files in the master branch. They are part of the project... – Basya Jun 11 '20 at 18:32
  • No the linter that is used by the dev team should not be dowloaded by the end user. That just one of many exemples. For the tutorial, as you said in the last comment, they assume everything in dev is relevant for master. – ninjaconcombre Jun 12 '20 at 06:34
  • You're fighting against normal git practices; this is going to be a very annoying and manual process to do. Instead, find a way to only *view* the merge commits in `master` without all the commits in dev. This option might be called ["first parent"](https://git-scm.com/docs/git-log#Documentation/git-log.txt---first-parent) or similar. Also consider instead using `tags` to enumerate the stable releases. – pkamb Oct 20 '20 at 17:31

0 Answers0