In the same vein you can create git aliases for all snippets from this article. Now you can call it via git command: $ git both-merged This snippet shows only local merged branches, which have appropriate remote merged branches: $ comm -12 <(git branch -merged|awk '')Äonât forget to make it executable( chmod 755 git-both-merged), and you can also make a git alias for this script. By default, Git chooses origin for the remote and your current branch as the branch to push. The general form of the command is this: git push .Usually, itâs simple to remove local and appropriate remote branches at once. If you run the simple command git push, Git will by default choose two more parameters for you: the remote repository to push to and the branch to push. Tip for Github usersĪfter the last Github update, Branches page is divided into âYour branchesâ, âActive branchesâ and âStale branchesâ, and it shows same information as previous commands. Click on this avatar, and you will get Personal Settings. At the right most top corner area, there will be your avatar or profile pic kind of thing. This list should be reviewed more thoroughly to avoid losing important commits. After creating repository in Bitbucket we need to create one app password to perform various activities like push, pull etc. Similar snippet for not merged branches: $ for branch in `git branch -r -no-merged | grep -v HEAD` do echo -e `git show -format="%ci %cr %an" $branch | head -n 1` \\t$branch done | sort -r Now, you can delete own remote branches, and ask other authors to clean-up theirs: $ git push origin -delete branch-name This magic snippet provides all required information: $ for branch in `git branch -r -merged | grep -v HEAD` do echo -e `git show -format="%ci %cr %an" $branch | head -n 1` \\t$branch done | sort -r Would be cool to know last commit date and author. What if this branch is merged, but still used for feature development. Usually, remote repository is a big garbage heap of stale branches, if there is no responsible housekeeping person.Īfter previous git remote prune origin we should have synched list of remote branches.Īt first, we can find branches which are already merged in âmasterâ: $ git checkout masterÄ«ut this command does not provide much information. List referenced remote branches: $ git branch -rĬlean-up outdated references: $ git remote prune originĪnd Git automatically prunes all stale references. If some of them is just abandoned stuff that you donât need anymore, remove it with â-Dâ option: $ git branch -D old-abandoned-featureĪfter each git pull or git fetch command Git creates references to remote branches in local repository, but doesnât clean up stale references. Next, decide what to do with not merged branches: $ git branch -no-merged Now, remove all outdated branches with: $ git branch -d old-merged-feature We need to know what branches are already merged in âmasterâ and can be easily removed: $ git checkout master Just like the branch name master does not have any special meaning in Git, neither does origin. gitconfig Local branchesĪt first, list all local branches: $ git branch
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |