Home > OS >  Duplicate effort when switching branches? reinstall dependencies?
Duplicate effort when switching branches? reinstall dependencies?

Time:01-25

For example, I worked on a branch called abc, and installed dependencies and added code in package.json, setupTests.js, .gitignore etc.

and the branch abc is now under PR.(so everything from abc is not in master)

now i am working on a newly created branch, and you can guess all dependencies i installed and configured etc that done on branch abc is not here, so request me to re-do all these.

I wonder what is the best solution or if you also undergone such thing? thanks.

CodePudding user response:

If you want to continue working on changes from a previous branch where the changes are not yet in the master branch (as example under review, PR), then simply create a new branch on top of the old (abc) branch.

git checkout abc
git checkout -b <new-branch>

So you have all the previously created changes in your new branch.

But beware (!!!): if something is criticized in the open PR from branch abc and new changes are pushed, these changes must also be merged into the newly created branch in order to avoid conflicts.

git checkout <new-branch>
git merge abc

If the open PR from branch abc is approved, merged in master and the branch deleted, the source branch from new-branch will changed automatically to the source branch from the deleted abc, and this would be master. So you didn‘t have to change anything.

  •  Tags:  
  • Related