Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
612 views
in Technique[技术] by (71.8m points)

github - What to do with experimental non-merged git branches?

What are the current best practices with git branches that have been created to test out a solution to a bug and have not been merged because the review process show that they are wrong or there are better solutions to the problem?

An example. Project fizzbuzz has a bug report that reports a crash on empty fields.

  • I create a new branch handle-empty-fields and make two commit to that branch, "solving" the problem.
  • Then I submit that branch to the fizzbuzz project manager, linking it in the bug report.
  • Somebody finds an error in my fix, writes another patch and that patch get accepted.

Now the code in the handle-empty-fields my code is useless: it is not correct and cannot be applied any longer to the code, but it has been referenced in that bug report.

What should I do? Keep the branch? I will quickly end up with dozens of abandoned branch and git has no way to mark a branch as abandoned or closed. Remove the branch? But then people looking at that bug report will find it and get 404.

People are often suggested not to rebase their repositories because that will cause problems to other devs, especially downstream devs. What are the suggestions for feature or bug-fix branches?

Update: it looks like github never deletes the commits contained in pull requests. So, if you push your changes an turn them into a pull request, you can later delete the branch without losing any of your changes. Well, while github is still working ;).

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The way I do it is to give it a tag. Use a full tag and give it a descriptive name. Then you can delete the branch, so it doesn't show up in your branch listings, but because it's tagged, the branch can still be recreated by checking out the branch. All the commits on the tag will still be available, and you won't lose any commits in a git gc Something like this, perhaps:

git tag -a partialBugfixXXX -m"Tagging a branch that went into fixing bug XXX"

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...