0

I have a fairly complex workflow. My working git branch is master. Assume that there exists a local branch called push_branch.

I'd like to automate the following steps whilst staying from within my working branch master.

  • At a particular point in time, a commit to master is made with a user-specified commit message. This should trigger the following:

    1. An additional side_effect_file is generated.
    2. push_branch obtains the latest set of tracked files from master. It also receives the side_effect_file generated by the last commit made to master and adds to its staging index.
    3. A commit is made in push_branch (i.e. the side_effect_file is now committed in push_branch. (can use the same commit message as step 0 above or use a default commit_msg, it doesn't matter).
    4. push_branch pushes to github (or a suitable remote repo).

Here is a pictorial description of the desired workflow: complex_git_workflow

In essence, all the working happens in master, which acts like a one-way feed to push_branch. The real challenge is to automate the process seamlessly, whilst staying inside the working branch master (or at-least appears seamlessly to the user by using a shell script which runs in the background).

What I don't want to do is to manually checkout push_branch, do a manual commit after adding side_effect_file, issue a commit message, do a manual push and then checkout master again. That is tedious, and not a sustainable solution.

Is this achievable? Maybe using git-worktrees (which I don't understand well)?

  • what is the side_effect_file. Will this file be merged to master at all? – karthick Jun 01 '18 at 21:06
  • It looks like you need git hooks https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks – undg Jun 01 '18 at 21:09
  • Here is example with `post-receive` in use from githooks https://gist.github.com/noelboss/3fe13927025b89757f8fb12e9066f2fa maybe you can use some ideas from it. – undg Jun 01 '18 at 21:19
  • The ```side_effect_file``` is an important file that gets generated post-commit containing the SHA of the commit and a few other information. – Dr Krishnakumar Gopalakrishnan Jun 01 '18 at 22:09

0 Answers0