Git - Best Practice: How often do I switch between branches and avoid multiple commits?

I am working on verification software. I save the main branch code, which is always ready to run tests. Therefore, I am developing new functions in other industries (dev for ex). This is a classic git workflow.

My concern is that I need to switch betwen master and dev 10 times a day, because the designers are asking me to check for their updates.

At the moment I know only one way:

  • Finish my work on dev with the message β€œregression required”
  • Switch to Lead Branch
  • Run a regression and give feedback
  • Go back to dev and keep working.

This is annoying due to the useless story created in dev branches.

Is there another simple way (I'm new) to avoid multiple commits in the dev branch?

Thank you for your help!

+3
source share
4 answers

Before switching branches, do git stash. This will record the current state of what you are working on, so that it can be easily restored. When you get back to the dev branch, do it git stash pop. This will reapply these changes and delete the wallet so that it does not remain in your history.

+4
source

I think that git stashis what you need. There will help here .

+1
source

git clone - . git pull . ( ).

+1

Some good suggestions here. My first thought is to have two clones, on dev and one on the host. Just change directories (similar to what ydroneaud says).

Another way, if you just want to trigger a regression, is to use the git archive to extract the snapshot and validate with it. Go to the empty directory and do:

git --git-dir=/my/dev/clone/.git archive master | tar xvf -

then build and check. Of course, it makes sense to put this in a script.

0
source

All Articles