Domanda

I'm an individual dev that started using Git (Git Extensions on Windows) several days ago mainly to allow working on my code from multiple computers. I'm slowly getting the gist of it. But my main problem is working out what to do with temporary feature branches once I've merged them into the main branches and trying to keep everything clean on all my machines.

As an example, let's say I'm currently working on a feature on my desktop that will take a while. I'm only half done so I commit and push this feature branch to Bitbucket so I can continue working on it when I get home. At home I do a pull, finish the feature and merge it into the 'dev' branch. Now I delete the feature branch locally as it's not needed anymore. But obviously it still exists on remote, and the refs are still there on my work pc.

My main question is, when and how should I delete these branches that aren't needed anymore? The easiest way I've found is to delete them on Bitbucket then prune them on all my developer pc's. But that means doing this on every pc locally. Is there an easier way to somehow delete a no-longer needed branch on one pc and propagate that change through to all my local repos?

È stato utile?

Soluzione

The easiest solution is to delete the branch on Bitbucket when you delete it locally (git push --delete origin mybranch). Then just always run git fetch --prune in other repos, and the branch will disappear there as well.


You can also set the git config option fetch.prune (git config --global --add fetch.prune true). Then git fetch will always behave as if you specified --prune.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top