Jump to content

Recommended Posts

Posted

Hi guys,

I just wrote a tiny script to help me with managing my way I handle my custom 'projects' and how I can easily create full-patches to apply to a custom server

or

"little patches converting to one big patch"

My workstyle:

- I never touch master (cause I often need it as reference)

- every little project I start in a new branch

- I use one branch only for mergeing in my little branches.

But sometimes ofc there is a conflict, which ofc I would prefer to solve in the branches only containing the one project, but I didn't yet figure out how I can merge serveral branches with merge-conflict-commits into one branch - if this one branch already has previous conflicted versions of the little-branches merged,

so, what I do is, I reset my merge-branch and merge all (conflict-solved) little branches, and therefore I do have this script:

#!/bin/sh

BRANCHES="dev-branch1 dev-branch2 .."

## Usally this works best to remerge from a clean master
echo "reset to master?"
read line
if [ "$line" = "j" -o "$line" = "y" ]
then
 git reset --hard master
fi

## Process the listed branches
for i in $BRANCHES
do
 echo "merge $i ?"
 read line
 if [ "$line" = "j" -o "$line" = "y" ]
 then
   echo "Start mergeing branch $i"
   git merge "$i"

 fi
 if [ "$?" != "0" ]
 then
   ## Something went wrong
   echo "Something went wrong with mergeing $i, Press CTRL+C to abort"
   read line_
 fi
done
echo "all done"

Ofc this might be a stupid way to handle these things, but I don't know (yet) any better - so here you go :)

(p.s. should work in a git-bash on windows, too)

  • 2 months later...
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use