(Unfortunately "nice, digestible" doesn't apply to the formatting of the scripts themselves. for branch in `comm -12 <(git branch -merged|awk '')` do echo -e `git show -format="%ci %cr %an" $branch | head -n 1` \\t$branch done | sort -r Whether you use GitFlow, GitHub Flow or any other branch driven development strategy, you will inevitably end up with a local Git repository filled with branches you no longer need. If you're collaborating, some fancier mini scripts like this one will present things in a nice, digestible format with dates and authors. In particular the git branch -merged command identifies branches that are safe to delete due to being merged to your mainline (or whatever branch you care about). There is overlap with some of what's already been discussed here but the focus is on housekeeping: deleting branches, remote and local, that are no longer needed in a collaborative environment. Perhaps a bit tangential but the perspective of this site might help to understand the general topic of deleting branches: Pruning with git fetch -p (or git fetch -prune, or git remote prune) removes the local information on remote branches which have been deleted. Syncing with git fetch updates all the local information on remote branches so they match the state on the server (strictly speaking, remote repository, wherever that is), but without deleting any local information on remote branches. This information isn’t synced automatically, so when your colleague deleted the release branch on the server, your local git repository didn’t lose its notion of a remote release branch. So when you first clone a repository, you get a complete copy, and your local git “knows” about all the remote branches as well as your local branches. Git repositories are complete, whether on your own system or on the server. Will no longer show the deleted remote branch. This will update your local repository with all the changes made to the remote repository, but without updating any of your local branches. When branches are deleted remotely, you need to prune your local repository - the easiest way to do this is with git fetch -p
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |