0

I would like to create a custom command for Git that is going to make rebasing on develop before I get ready for a pull request easier. Right now the current workflow is;

  • checkout develop
  • fetch
  • pull
  • checkout my current branch
  • rebase -i
  • commit
  • push

I would love the be able to run everything up to and including the rebase command with just a simple custom command. I was reading this article about custom commands which seems like it could do exactly what I want with one small exception. I would like to be able to store the current branch name and then after checking out develop and fetching/pulling then switch back to the original branch before the rebase.

Adam H
  • 1,750
  • 1
  • 9
  • 24

1 Answers1

1

Pull already does fetch so the pipeline looks like this:

  1. checkout develop
  2. pull
  3. checkout my current branch
  4. rebase -i
  5. commit
  6. push
  7. (Later: merging to develop at some stage, but this may be done via some web Gui, I don't know your setup )

I think it's OK to automate 1,2 3, and 4, but the other steps are important steps that require attention and even step 2 may create errors (depending on your flow).

Back to original question, you can rebase develop without switching to it:

>git fetch origin develop && git rebase -i origin/develop

From How to switch back to previous branch after git pull? by Mark Reed

This leaves us with:

  1. Rebase develop onto the feature branch
  2. Commit
  3. Push
  4. (later: merging to develop at some stage)

which I think is pretty...pretty :)

tymtam
  • 31,798
  • 8
  • 86
  • 126