-
Notifications
You must be signed in to change notification settings - Fork 11
Description
We are thinking about adding to Fork a feature which would help teams to keep clean history.
As you know it's pretty difficult to have a clean history in git. I've got some ideas and tricks how that can be achieved. Briefly: create a separate branch for each feature, synchronize your changes with the main
branch using rebase and merge back to main
at the end. My point of view is similar to what Chris Manson suggests in his great article (https://simplabs.com/blog/2021/05/26/keeping-a-clean-git-history/, I really recommend to read it if you haven't yet).
Here's an example of a decent git history:
The commit history may look simple and clear, but making it so is surprisingly difficult and requires the use of some advanced (and dangerous) git features. In particular:
- rebase (to rebase on
main
) - force push with lease (to update the remote tracking reference after the rebase)
- hard reset (if something went wrong and we want to start from scratch).
We are thinking about adding to Fork the ability to easily make those operations and perform dangerous things automatically (without hiding them, though!). Something like git-flow, but not so complicated and with a dedicated sync
option. We called it "Lean branching" trying to reflect the approach but may be there could be a better name.
Goals:
- Be simple
- Keep history clean by default
- Do not introduce a naming convention. Fork can work with
main
,develop
ormaster
. - Intuitive for advanced users
- Easy to explain to non-developers
The workflow is supposed to be like the following:
- Start a branch on
main
- Commit changes. Sync with
main
as often as possible to minimize future conflicts - When the work is done, finish the branch by merging it into
main
So, there are just 3 actions:
1. Start new branch
Create and checkout new branch on main
or origin/main
(depends on which one is ahead)
2. Sync active branch
- rebase on the remote tracking branch (if needed)
- rebase on
main
(if needed) - restore the remote tracking branch position on the new location using force push. So, if it was 2 commits behind the branch, it will remain 2 commits behind after the sync
If the active branch is main
, sync will simply rebase it on origin/main
3. Finish active branch
- merge the current branch into
main
, but use fast-forward if the branch consists of a single commit.
precondition:main
must be in sync withorigin/main
Simple example:
I've finished working on FW-433
and want to merge the changes into master
:
Sync
FW-433
with master
first:
Now I can test if everything works properly and then push master
.
A few notes:
- Your changes will not be pushed or fetched automatically. You must do that yourself, same as you do now.
- All 3 actions are available in the
Branch
dropdown on the toolbar in Fork - The underlying git commands can be seen in the activity manager if you click on the status control on the toolbar
Tanya and I have been using this feature 'as users' for some time and it works really well for us.
It would be great if you could try it and let us know what you think.
You can download the build here: https://cdn.fork.dev/prerelease/ForkWin-1.69.10.zip. Extract it somewhere and run fork.exe.
Use with caution, it's still in beta.