![]() ![]() Pushing to delete remote branches also removes remote-tracking branches ![]() The following sections describe additional details to consider when deleting your remote and remote-tracking branches. To delete that actual remote branch, you need git push origin -delete bugfix Which only deleted his local remote-tracking branch origin/bugfix, and not the actual remote branch bugfix on origin. The original poster used: git branch -rd origin/bugfix The local remote-tracking branch origin/X that tracks the remote branch X.When you're dealing with deleting branches both locally and remotely, keep in mind that there are three different branches involved: The long answer: there are three different branches to delete! Git fetch -prune # Delete multiple obsolete remote-tracking branches Git branch -D # Force-delete un-merged branchesĭeleting a local remote-tracking branch git branch -delete -remotes / Git push origin : # Git versions older than 1.7.0ĭeleting a local branch git branch -delete Git push origin -d # Shorter version (Git 1.7.0 or newer) Deleting a remote branch git push origin -delete # Git version 1.7.0 or newer If you want more detailed explanations of the following commands, then see the long answers in the next section. Scott Chacon was right-I will want to dog-ear that page (or virtually dog ear-by answering this on Stack Overflow).įinally, execute the following on other machines to propagate changes: # Fetch changes from all remotes and locally delete I ran git push origin :bugfix, and it worked beautifully. If you leave off the portion, then you’re basically saying, “Take nothing on my side and make it be. A way to remember this command is by recalling the git push : syntax that we went over a bit earlier. You may want to dog-ear this page, because you’ll need that command, and you’ll likely forget the syntax. If you want to delete your serverfix branch from the server, you run the following: $ git push origin :serverfixīoom. You can delete a remote branch using the rather obtuse syntax git push. Suppose you’re done with a remote branch - say, you and your collaborators are finished with a feature and have merged it into your remote’s main branch (or whatever branch your stable code-line is in). ![]() Delete Remote Branch įrom Chapter 3 of Pro Git by Scott Chacon: Deleting Remote Branches ![]() Therefore, the version of Git you have installed will dictate whether you need to use the easier or harder syntax. Starting with Git v2.8.0, you can also use git push with the -d option as an alias for -delete. Which was added in Git v1.5.0 "to delete a remote branch or a tag." Which might be easier to remember than $ git push : You will receive an error if you try to delete the currently selected branch.Īs of Git v1.7.0, you can delete a remote branch using $ git push -delete.As of Git v2.3, git branch -d (delete) learned to honor the -f (force) flag.The -D option is an alias for -delete -force, which deletes the branch "irrespective of its merged status.".The -d option is an alias for -delete, which only deletes the branch if it has already been fully merged in its upstream branch.To delete the local branch, use one of the following: git branch -d ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |