gitless
gitless copied to clipboard
Shortcut to publish to origin?
One of the overly complicated parts of git is pushing a branch to origin. I think every time I've ever pushed a branch I've pushed to the same remote repo with the same branch name as the one I'm working on. (Although potentially I'm not like most people?)
So if I'm working on feature, in git I use git push -u origin feature. Of which -u origin feature is superfluous.
Gitless seems to add a step - is that the case? i.e. you have to use gl branch -c origin/feature first?
Thanks, Max
I'm not sure I follow...
If you have an 'origin/feature' upstream attached to a 'feature' branch that is local, you can simply do a 'gl publish' (following a 'gl commit' describing your changes) to push from the local branch to the upstream branch.
Doing 'gl branch -r' will list all branches, including remote branches. Note that your local branches with upstream attachments have a paranthetical that follow their description.
feature (upstream is origin/feature) another-feature
Note how 'another-feature' currently doesn't have an upstream specified.
Am I missing something in your description?
Sorry not to be clearer.
This is the case before you've created the remote branch. So
- you're on
master - you branch off to
feature - you want to publish to
origin/feature
My suggestion is that's a very very common path, and one that gitless could make less verbose (it's more verbose that git at the moment). For example, having gl publish be synonymous with git push -u [default remote] [current branch name].
Thanks
I wonder if it's possible to go further here and make it the expectation that every local branch name matches a remote branch name (and require the user to take steps to do things that violate that).
Then you could just do (assuming you're on branch 'new-branch'):
gl publish # effectively "git push -u new-branch origin", perhaps with confirmation
gl publish otherremote # git push -u new-branch otherremote
So far, I find the publish feature to be intuitive.
When you create a local branch that mirrors an existing remote branch, you can associate the local branch with its respective remote branch via:
gl branch -su remote_repo/existing_branch
Then, you can use gl publish to push changes to its respective remote branch.
If the remote branch does not already exist and you wish to create and publish your changes in one step, I find it helpful to specify the -dp option with the local branch when executing the gl branch -c command. For example, the following command creates a new branch in a remote repository that mirrors the local branch:
gl branch -c remote_repo/new_remote_branch -dp existing_local_branch
When I need to push the same commit to multiple existing remote branches, I tend to do the following:
-
Create a new local branch that mirrors the branch in the remote repository:
gl branch -c new_local_branch -dp remote_repo/existing_remote_branch -
Switch into the new local branch:
gl switch new_local_branch -
Associate the new local branch with its respective branch in the remote repository:
gl branch -su remote_repo/existing_remote_branch -
Obtain the most recent commit ID from the existing local branch:
gl history -l 1 -c -b existing_local_branch -
Fuse the commit from the existing local into the mirrored local branch:
gl fuse existing_local_branch -ip HEAD -o commit_id_from_step4 -
Resolve any merge conflicts:
gl statusEdit the indicated files to resolve conflictsgl resolve path/file_namegl commit -
Push the new commit from the mirror branch into its respective remote branch:
gl publish -
Delete the mirrored local branch:
gl branch -d new_local_branch
Sincerely, Al
:+1: for this idea because this flow is so common and it's in line with the gitless philosophy.
- I'm on master
- I want to create a new branch locally which tracks an identically named branch on a remote.
I'm just now realizing how many times in my life I've typed two or three commands to achieve this.