{"id":110287,"date":"2024-09-20T07:00:00","date_gmt":"2024-09-20T14:00:00","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/oldnewthing\/?p=110287"},"modified":"2024-09-20T09:16:46","modified_gmt":"2024-09-20T16:16:46","slug":"20240920-00","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20240920-00\/?p=110287","title":{"rendered":"How can I check that all the changes in a git branch have been cherry-picked or rebased into its upstream branch?"},"content":{"rendered":"<p>If you try to delete a branch that contains changes that haven&#8217;t been merged to its upstream, git warns you, <tt>the branch is not fully merged. If you are sure you want to delete it, run 'git branch -D xxx'<\/tt>. Suppose you want to check that all of the changes in the branch have been cherry-picked or rebased into the upstream branch. How can you confirm this? How can you do the &#8220;If you are sure&#8221; step?<\/p>\n<p>One way to do this is to merge the branch into its upstream and see if the result produces any changes.<\/p>\n<pre># Detach the HEAD from the upstream so we can do some tinkering.\r\n$ git checkout --detach featurebranch{@u}\r\n\r\n# Propose a merge of the feature branch.\r\n$ git merge featurebranch\r\n$ \u27e6 resolve any merge conflicts and commit \u27e7\r\n\r\n# See if anything would have changed.\r\n$ git diff HEAD HEAD~1\r\n\r\n# Return to original branch, abandon detached HEAD.\r\n$ git checkout -\r\n<\/pre>\n<p>If the <tt>git diff<\/tt> produces no output, then everything in your <tt>featurebranch<\/tt> is already present in the upstream, so you can delete the <tt>featurebranch<\/tt>.<\/p>\n<p>If the <tt>git diff<\/tt> produces output, then there is content in your <tt>featurebranch<\/tt> that is missing from the upstream, so you want to look at those changes and see if they are worth keeping.<\/p>\n<p>The older the <tt>featurebranch<\/tt> is, the more likely that you&#8217;ll get a merge conflict when doing a test merge with its upstream, since that gives the upstream more time to make a conflicting change to the files that you changed in <tt>featurebranch<\/tt>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>You can pretend to merge it and see if anything happens.<\/p>\n","protected":false},"author":1069,"featured_media":111744,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[26],"class_list":["post-110287","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-other"],"acf":[],"blog_post_summary":"<p>You can pretend to merge it and see if anything happens.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/110287","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/users\/1069"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/comments?post=110287"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/110287\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media\/111744"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media?parent=110287"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=110287"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=110287"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}