Sourcetree Git Flow Finish Feature Merge Target Configuration
0 reputation · 26 Oct 2021, 04:25 UTC
0 reputation · 26 Oct 2021, 04:25 UTC
When using Sourcetree’s Git Flow extension to finish a feature, the tool must decide which branch receives the merged changes.
The expected behavior is that the feature branch is merged into the integration branch defined for the flow (commonly develop). However, if a repository has renamed its integration branch (e.g., using main instead of develop) or has customized the branch mapping in Sourcetree’s Repository Settings, it is unclear which source the tool consults to determine the target.
Does Sourcetree prioritize the Git Flow configuration stored in the repository’s .git/config, the branch names displayed in the Repository Settings UI, or fall back to the default names hard‑coded in the extension? What happens when these sources conflict, and how can a user verify the actual merge target before completing the finish action?
35275 reputation · 26 Oct 2021, 05:29 UTC
Sourcetree prioritizes the Git Flow configuration stored in the repository's .git/config file. The Repository Settings UI in Sourcetree acts as a graphical interface for this specific configuration file; changes made in the UI are written directly to the [gitflow] section of the local git config.
When you trigger the "Finish Feature" action, Sourcetree resolves the target branch using the following hierarchy:
gitflow.branch.develop) in .git/config.develop for the integration branch).If you rename your integration branch (e.g., from develop to main) using the Git CLI or a different tool without updating the Git Flow settings, a conflict occurs. Sourcetree will attempt to merge the feature into the branch name still listed in the [gitflow] config. If that branch no longer exists, the operation will fail.
To ensure your feature merges into the correct target, use these verification methods before completing the action:
.git/config file in a text editor and verify the [gitflow] section. Ensure the branch.develop key matches your current integration branch name.Diagnostic Note: Are you using a shared .gitconfig (global) or a local repository configuration? Git Flow settings are typically local to the repository, but global overrides can occasionally cause unexpected behavior in specific Sourcetree versions.
Use comments to ask for clarification. Post a solution as an answer.
35,275 reputation · 26 Oct 2021, 09:33 UTC
To clarify the target resolution, Sourcetree typically follows a specific hierarchy: it first checks for a gitflow.branch entry within the .git/config file. If that is absent, it refers to the branch mapping defined in the Repository Settings UI, finally falling back to hard-coded defaults (usually develop) if neither is configured.
A critical point for verification is that changes made in the UI mapping may not always synchronize with the .git/config file, which can lead to configuration drift. To ensure the correct target is being used before executing a merge, you can perform two checks:
git config --get gitflow.branch in the terminal to see the explicit configuration stored in the repo.