-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
⭐️ Lean Branching - a git branching model to keep clean history #1432
Comments
I'm running 1.69.10 but I can't see the new actions in the branch dropdown or anywhere else. Do I need to do something to activate them? |
@Calneideck
Is it possible that your local |
@DanPristupov Thanks, that was it! I had |
Is this the branching model that has just been released with the Fork 1.70.0? |
@mloskot let's keep it open for now. We are still looking forward to hear feedback from people who tried it :) |
I gave it a quick try. I really like this git methodology in general. I am used to working with branch protections, disabling any pushes to I don't see myself using this in day-to-day operations but I can see it being helpful for others. |
I like it but I think it should be possible to do the actions while there are uncommitted changes as well, which is the case in most of my repos. |
@LievenDeFoor this is a good point. I agree, |
Could these names be made configurable? |
For 'force push with lease' to work correctly don't you need to disable automatic fetching ('Fetch remotes automatically' in General config) ? |
@jnunnerley may be I'm missing something, but I think automatic fetch is not related. |
The following details the issue https://blog.developer.atlassian.com/force-with-lease/ Do you do the workaround? |
Another remark (sorry!): |
I was loving it until last update that made the sync operation mandatory. For non-dev users, rebase is harder to understand than merging (and it makes the history unclear for us). Could you let an option to let us merge without rebasing (like in the beta build) ? |
@jnunnerley do you mean the race condition, when new remote branch position could be fetched right before the push and would be overwritten? It shouldn't be a problem, because we can use @LievenDeFoor
Is there any real reason behind that? Having 2 commits for a single commit change definitely contradicts with the original goal 'clean history' and even with the name (it's not a
Then, why do you want to use 'lean branching' and not just merge (or even gitflow)?
I don't remember it working that way. If it was, I guess, it was a bug. The whole point of the lean branching is to rebase before the merge. |
@DanPristupov The main problem with using gitflow with fork right now (for non dev users) is that it's really easy to start a feature branch, but really hard to finish it (we need to search for it in quick launch). The lean branching added the "Finish feature" option that we use on our workflow, directly on the branch button. |
@Francoimora I'll have a look if we can add the 'finish feature' for gitflow. |
Company policy. No direct commits on master/develop/main... are allowed to be pushed, except for merge commits. |
I love this idea. I've been training my staff to work like this for years now, but due to the risks inherent with rewriting history, it's always had a bit of a learning curve. We do this on develop and then use merge commits on master to indicate when releases went to production. It makes it very clear what work went into a feature, and what features went into a release. For example: I agree with others that it would be nice to have the branches configurable (perhaps in the repository settings?). Would it be possible / make sense to put this under the right-click menu as well (perhaps also based on config)? |
@rmarskell thank you for sharing your use case.
I also noticed a bug, that 'develop' must be a higher priority than 'main'. So, in your case 'develop' must be used by default.
Yes. In the next update we will make the main branch configurable. |
I see what you mean. Yes, I suppose there would need to be some idea of which takes precidence. This rebasing structure doesn't really work with multiple levels (i.e. rebasing develop onto main, if it had changes, would lose the benefit of being able to see feature branch history since I think the rebase flattens the merge commits). If you can configure the branch to use for rebase/merges in the repository settings (so you can work on differently structured repos), that should work fine for us. :)
🎉 |
BTW: This also affects interactive rebase. There, the missing stashing option is bugging me as well. ;-)
This is a highly opinionated topic. And while Github or Bitbucket do allow the option to switch this behavior for each and every PR/MR. Gitlab does not allow this. There you can only set the general setting to either only allow fast-forwards or only merge-commits. |
I also dislike changes that get made during a merge. My personal practice is to merge main into my feature branch immediately before merging my feature branch back into main and closing it. The first step makes it clear which changes were needed to integrate the changes made in main into my feature branch. I can test that integration and make any necessary changes while still in my feature branch. After that, merging my feature branch back into main is trivial (no conflicts) and shows only the changes needed to implement the feature (without any conflict resolutions mixed in). My git knowledge is pretty shallow, so there might be a better way. |
The only thing that I dislike about this whole new feature is how it makes fork an opinionated tool towards a specific workflow. By putting this near the center of the header it will make some individuals and teams believe that this is "the" way to work with Git and everything else is "too complicated". I like fork especially because it allows me to do the same things as on the command line, mostly with a better UI, without restricting me too much. Every other tool I tried so far exposed me to different terminology than Git itself or promoted ways of working that only made sense in a specific setting. This makes it hard to even talk and reason about different aspects of Git workflows if knowledge of developers is only based on a specific UI instead of Git itself. When I tell a team member that they have to "sync" their branch with main I want them to follow our workflow, not accidentally find something in a tool they don't fully understand. I appreciate the idea to give fork the support for different workflows. It would be great if this was an optional (as in opt-in) and pluggable feature, perhaps as a set of predefined custom commands. Then I could decide to use it or not, and otherwise not be bothered with it. And I could define my own workflow and reach the required menu items easily. |
The new feature seems cool, my only issue is it assumes you work entirely off of master. Our sprints come off of master and our user stories come off of sprints. So for this to work for that sort of model, we'd need to be able to configure the branch we start, sync, and finish with. Instead of master, we'd be starting, syncing, and finishing on our user story branches with our sprint branches. Can a setting be put into place to configure master / main to be any branch in the repo? |
@JosephTLyons we will the ability to change the main branch in the next update (Fork 1.71 Windows). |
@DanPristupov |
This looks to be a very useful feature and it will help massively with our standards & practices. Could I request a setting to remove the branch once it has been finished, please? |
No, I believe, the user must push and delete the branches manually and explicitly. It should not be an automatic action. |
Ok. It looks like this was designed to solve a different problem than what we need it for, in that case. |
I love this feature and suggest to make this even more prominent in the gui: the sync-action could be added to the top-level fetch, pull, push buttons. |
I love this feature! It enforces a good practice for keeping the commit history clean :)
|
Repository -> Settings for this repository -> Lean Branching -> Main Branch There's no develop, though. |
Oh! Thanks for pointing this out, I haven't explored much in repository settings |
@DanPristupov any update on the "stash and reapply" on finish feature (in addition to on sync)? |
@LievenDeFoor I think working directory must be clean before both 'merge branch' and 'finish feature' operations. |
@DanPristupov It surely doesn't have to be clean for 'merge branch' unless Fork is doing a stash before and reapply after merge automatically. |
@DanPristupov There is one problem when I "Sync" now: When I sync local branch on release, Fork alarms " |
@HongliangQiu can you send the log file |
Ok, please wait a minute. |
@DanPristupov I have send one email, please check it. |
@HongliangQiu thank you for the bug report! I've just released Fork |
Ha, I have downloaded the latest version, everything is ok now. |
Can I also create a pull request on |
@DanPristupov When I Sync A branch, Fork encounters Merge Conflict. |
@HongliangQiu it's probably a conflict when merging the local changes that were stashed before sync. |
My local workspace is clean. |
OK, it's difficult to say what's going on. Try to open Console and reset the sync by running |
It works. Thank you very much. |
I just found the 'lean branch' options, this has been my workflow precisely for forever, and I've been using Fork forever, sad for me that I was unable to put the two together until now hahah. Thank you for adding this! 😁 However, I just noticed these commands don't show up in the ctl-p menu, would it be easy to add them there? Or, giving them a keyboard shortcut as mentioned above? Basically, it's the kind of thing I'd naturally trigger from the keyboard, as with pulling, to quickly make sure I'm always up-to-date, so some keyboard-centric trigger would be great... |
I'm using fork since before the lockdown and got it approved for the whole team back in 2019. I'm still using it personally (my own licence since I do support great tools) and use it as my sole git client. It's just awesome. Regarding the "lean branching", I like this very much, as this is sort of the mode of operation I prefer in our trunk-based model. The only whish I have: can the lean branching also be applied to an already existing feature branch (the initial branch get's created off main but through a jira ticket) and instead of finishing the whole thing with a direct merge into main, could this just push-force-with-lease to origin and create a PR (in azure devops) which then will be merged into main anyways if approved? |
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 tomain
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:
main
)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:
main
,develop
ormaster
.The workflow is supposed to be like the following:
main
main
as often as possible to minimize future conflictsmain
So, there are just 3 actions:
1. Start new branch
Create and checkout new branch on
main
ororigin/main
(depends on which one is ahead)2. Sync active branch
main
(if needed)If the active branch is
main
, sync will simply rebase it onorigin/main
3. Finish active branch
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 intomaster
:Sync
FW-433
withmaster
first:Finish
FW-433
:Now I can test if everything works properly and then push
master
.A few notes:
Branch
dropdown on the toolbar in ForkTanya 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.
The text was updated successfully, but these errors were encountered: