Floating commit in git

In our project, as usual, we have the main branch. Based on this is the deployment branch, where the settings are changed. Also based on this there is a mirror branch that launches a deployment mirror. The master branch should not contain any changes that change the configuration.

Minor features and fixes developed in the mirror branch. Therefore, after adding a function, it looks like this:

master: history โ” deployment: โ”œโ”€ deployment-config mirror: โ””โ”€ mirror-config โ”€โ”€ feature 

Now, to move the function back to master, I must first change the order of corrections in the mirror branches:

 master: history โ” deployment: โ”œโ”€ deployment-config mirror: โ””โ”€ feature โ”€โ”€ mirror-config 

Now I can rewind back and forth in master

 master: history โ”ฌโ”€ feature โ” mirror: โ”‚ โ””โ”€ mirror-config deployment: โ””โ”€ deployment-config 

And then combine the master in the mirror and reinstall it on the master

 master: history โ”€โ”€ feature โ” mirror: โ”œโ”€ mirror-config deployment: โ””โ”€ deployment-config 

Is there a plugin or tool to automate this, so

  • each new commit is automatically applied โ€œbelowโ€ the top commit,
  • each merge or cherry pick is also automatically applied โ€œbelowโ€ the upper fix,
  • merging from such a branch is pulled out of the state "below" the upper commit?
+4
source share
2 answers

In general, I would recommend trying and getting away from this configuration fixing situation. Can you save the configuration during deployment? Or use lubrication filters, as I explained here: fooobar.com/questions/1454076 / ...

If this is not an option, let me answer your questions, as there are easier ways to achieve what you want, thanks to the fact that branches in git are so easy. None of them are fully automated, but quite simple, and you can definitely write small scripts for it.

each new commit is automatically applied โ€œbelowโ€ the top commit

Not quite sure about the situation, but assuming you made changes and want to commit them:

  • Remember that your current SHA branches
  • Click your changes
  • git reset --hard HEAD^
  • stash pop
  • commit
  • cherry-select your branch-branch

each merge or cherry pick is also automatically applied โ€œbelowโ€ the top fix

same as above: reset --hard , do your job, old cherry branch

merging from such a branch is pulled out of the state "below" the upper commit?

It is very simple: git merge mybranch^


If you do not want to change your working directory, and files changed by your "config" are not affected by your other operations, you can do this:

  • Remember that your current SHA branches
  • Do a soft reset: git reset HEAD^
  • Make git ignore your config files via git update-index --assume-unchanged
  • create commit
  • run git update-index --no-assume-unchanged for your config files
  • commit again - this will re-create your configuration files.

If you automate this with a script, you can use git to get a list of configuration files for --assume-unchanged by looking at the configuration commit. If you do not want to automate this, you can skip steps 3 and 5 and just make sure that you do not execute your configuration files in step 4.

+4
source

What can automate reordering is git rebase -i --autosquash , which can reorder / squash for you, based on the commit message:

If you know which commit you want to crush something, you can pass it the message " squash! $other_commit_subject ".
Then, if you run git rebase --interactive --autosquash commitish , the line will be automatically set as squash and placed under commit with the theme $other_commit_subject .

(For details, see the second part of GIT Trimming Checking / Twisting GIT History ")

It may be an idea to facilitate the reordering of the "functions" combined, especially if you have a "function" and a "mirror-config" are performed together.

After reordering a rebase --onto can move these merging functions to the desired branch.
See, for example, Integrated GIT Redirection Maneuver . "

In addition, I do not know a single plugin that could automate these tasks: all about git rebase .

0
source

All Articles