gitless
gitless copied to clipboard
"gl branch -c origin/test1 -su origin/test1" publishes local commits
The command gl branch -c origin/test1 -su origin/test1 has the unexpected side effect of publishing local commits of the current branch to origin.
It is unexpected in terms of orthogonality with the gl publish operation.
When we create and set the remote branch as upstream we may not have yet finished with local branch editing. I expected that uploading commits would be done with gl publish only.
This behavior is documented on the Gitless site:
Each branch has a head, which is the last commit done on the branch. By default, the head of a new branch is going to be equal to the head of the current branch. If you want a different commit to be the head of the new branch you can provide one with the dp/divergent-point flag.
I consider this behavior a positive feature rather than a problem. In fact, I have become quite dependent and accustomed to this behavior.
At work, we are assigned our own personal private Github repository to do with as we please. To avoid the uncertainty of what code gets published into a newly created branch, I always specify the -dp parameter with the name of the local or remote branch with the source code I wish to populate the new branch every time I use gl branch -c.
Here is my use case:
-
Create a new local branch that mirrors an existing branch in the remote public repository:
gl branch -c new_local_branch -dp public_remote_repo/new_remote_branch -
Create a new remote branch in my assigned private repository that mirrors my local branch to back-up my work for the day:
gl branch -c private_remote_repo/new_remote_branch -dp new_local_branch(optional)gl branch -d new_local_branch -
Create a new local branch that mirrors the new branch in my assigned remote private repository in order to resume working locally:
gl branch -c new_local_branch -dp private_remote_repo/new_remote_branch(optional)gl branch -d private_remote_repo/new_remote_branch
Sincerely, Al