Replies: 7 comments 6 replies
-
Good detailed background on this topic How to use rebasing properly - Golden Rule My view - rebasing is a good idea and safe but is must be done locally on a devs private branch Following this workflow: Local Cleanup One of the best ways to incorporate rebasing into your workflow is to clean up local, in-progress features. By periodically performing an interactive rebase, you can make sure each commit in your feature is focused and meaningful. This lets you write your code without worrying about breaking it up into isolated commits—you can fix it up after the fact. When calling git rebase, you have two options for the new base: The feature’s parent branch (e.g., main), or an earlier commit in your feature. We saw an example of the first option in the Interactive Rebasing section. The latter option is nice when you only need to fix up the last few commits. For example, the following command begins an interactive rebase of only the last 3 commits.
By specifying HEAD~3 as the new base, you’re not actually moving the branch—you’re just interactively re-writing the 3 commits that follow it. Note that this will not incorporate upstream changes into the feature branch. |
Beta Was this translation helpful? Give feedback.
-
One thing I'm not sure about is how to deal with upstream changes. I like to merge them in ASAP because sorting out conflicts is easier than if all at once - but maybe that is not true? However if this is done, what does that do to rebasing? Not sure I understand this. I think that you cannot merge in upstream commits and then rebase because the upstream commits then get rewritten which is no good for other devs? Not really sure. No decision on what we do till this is resolved |
Beta Was this translation helpful? Give feedback.
-
What I do is periodically rebase my local branch on top of master:
This link explains To get any changes from upstream, you would not use Admittedly, this is more work than a simple git merge, but I think overall worth it. |
Beta Was this translation helpful? Give feedback.
-
How to deal with upstream commitsI'm still not certain about this. The issue about merging upstream commits is when your development on a feature goes for a long time before you have it fully working and therefore ok to put on master. In that case (I think) merging upstream commits into your feature branch helps because you are developing on the most recent version, Variants of force, and safety
See the answer to this question for an insightful description https://stackoverflow.com/questions/65837109/when-should-i-use-git-push-force-if-includes Summary: neither |
Beta Was this translation helpful? Give feedback.
-
One more thing: ideally the size of a PR should be quite small so they are easy to review. However, with FYP work (such as for myself and @adidesh20), I'm not sure what the best practice here is. I already have a lot of changes just for an MVP, and most of these changes are required in order to not break master. |
Beta Was this translation helpful? Give feedback.
-
One more thing before I do a full write-up: @tomcl I suggest you set up branch protection rules that disallow people from pushing directly to master. This will ensure everything goes via a code review and PR before it enters master. |
Beta Was this translation helpful? Give feedback.
-
Developers should try to follow the same processes when contributing to ISSIE to ensure changes are easy to follow and keep track of.
This would include:
Pull Requests
My personal preference is for PRs to be squashed. Note squash instead of rebase: this allows for PRs to be reverted more easily than a rebase, since the PR is contained in a single commit rather than many commits.
Pros:
Cons:
When rebasing, I prefer to do an interactive rebase (
git rebase -i master
), so I can see exactly how the git history will be changed.Developers should use
git push --force-with-lease
when pushing their work upstream after a rebase: this should help prevent loss of work.Note: I've found that using GitHub Desktop for rebases is a bit annoying. I always use terminal so this isn't a problem for me, but someone who is only comfortable using GitHub Desktop may struggle with rebases.
Commit Messages
Commit messages should be informative and concise. Someone reading the commit message should ideally be able to understand what that commit actually changes (e.g. 'fix bug' is not a good commit message).
Assuming that PRs are squashed: the PR should be named such that it is obvious what that PR resolves, since that name will be the commit message once merged.
Beta Was this translation helpful? Give feedback.
All reactions