Does a tree have to be pushed?
Closed this issue · 8 comments
When reviewing PRs for an org's repo, I don't have explicit git push
permissions, only to my fork.
So I can't add
a worktree because the command fails creating it (and then pushing it)
Hi @ericclemmons,
Nice observation.
At first, I didn't want to push the branch, but I had some issues.
Example:
I created a test branch from the master without pushing it.
But I got the error below when I tried to push the branch.
~/personal-projects/test (test ✔) ᐅ git push
fatal: The upstream branch of your current branch does not match
the name of your current branch. To push to the upstream branch
on the remote, use
git push origin HEAD:master
To push to the branch of the same name on the remote, use
git push origin HEAD
To choose either option permanently, see push.default in 'git help config'.
To avoid automatically configuring an upstream branch when its name
won't match the local branch, see option 'simple' of branch.autoSetupMerge
in 'git help config'.
My solution was to add the push command while adding the worktree.
(Push command: git push --set-upstream origin ${newBranch}
)
I can configure it for the user based on an environment variable,
if the user wants to push their branch automatically,
and add a comment in the readme about how you can push it to the remote.
I just think the user should execute a more complex push command each time.
This is my only solution for now. I still haven't found anything better.
=====
However, I can't understand your point about reviewing a PR.
If you want to review a PR, I assume the branch exists on the remote, and you want to create a local worktree from that branch. This will not push the branch, it will just create a new local worktree for you.
=====
Please let me know what you think.
@alexiszamanidis
How about we make auto pull/push a option in extension setting?
Hi @zcfan,
I truly appreciate your suggestion.
It's an excellent idea that aligns perfectly with enhancing the functionality of our open-source project.
I'm committed to implementing the "auto pull/push" option at the earliest opportunity.
In regard to this feature, I'd like to gather your insight on whether you envision it being enabled by default or requiring users to manually turn it on. From my perspective, having it enabled by default seems logical. This way, when users attempt their initial push, it could potentially preempt the error scenario you mentioned by ensuring their local repository is up to date with the remote repository. Your thoughts on this aspect would be valuable as we move forward with refining this feature.
Thank you once again for your valuable contribution and engagement with the project.
Looking forward to your insights!
@alexiszamanidis I prefer not to auto pull/push by default, since it's the default behavior of git worktree add
. Which means no "surprise" to newcomer.
But previous versions of your extension is auto by default, and it has so many users already!🎉 So keep consistent is also acceptable.
Personally I perfer not to auto pull/push, because the repo I'm working on is messy, remote commits might break my local workspace accidentally.
@zcfan
I understand the importance of maintaining consistency with the existing extension's auto-push behavior, especially given its established user base. However, your valid point about the default behavior being off aligns with Git's standard approach. It's crucial to consider both perspectives. In light of this, I'll proceed with the auto push option enabled to assess its impact and gather insights on user experience and workflow.
Hi @zcfan,
I am glad to inform you that the options have been added.
Please take a moment to check them out and provide valuable feedback on the work.
I apologize for any delay in implementing these changes - I was in a bit of a rush.
Looking forward to hearing your thoughts!
@alexiszamanidis Work like a charm, thank you!
Glad you like it!