Skip to content

allow to specify a remote in the publish command #242

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

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

glehmann
Copy link
Contributor

@glehmann glehmann commented May 2, 2018

this is especially useful when working with github's hub (https://github.com/github/hub),
to submit a pull request:

git clone [email protected]:kennethreitz/legit.git
git checkout -b my_branch
# code
git commit -am "my changes"
git fork
git publish glehmann
git pull-request

@kennethreitz
Copy link
Collaborator

✨🍰✨

this is especially useful when working with github's hub (https://github.com/github/hub),
to submit a pull request:

    git clone [email protected]:kennethreitz/legit.git
	git checkout -b my_branch
	# code
	git commit -am "my changes"
	git fork
	git publish glehmann
	git pull-request
@glehmann
Copy link
Contributor Author

glehmann commented May 2, 2018

I realize this is a non backward compatible change.
Any idea for a better implementation is welcome!

@weakish
Copy link
Collaborator

weakish commented Nov 12, 2018

The current implementation is consistent with git push, i.e. both git push <REMOTENAME> <BRANCHNAME> but breaks backward compatibility.

On the other hand, git publish <BRANCHNAME> <REMOTENAME> will not introduce non backward compatible change, but may feels confusing since the order is reversed as git push.

Maybe git publish [branch] [--to remote_name]?
And the corresponding option for unpublish is git unpublish [branch] [--from remote_name]?

git clone [email protected]:kennethreitz/legit.git
git checkout -b my_branch
# code
git commit -am "my changes"
git fork
git publish --to glehmann
git pull-request
# after merging pull request
git unpublish --from glehmann

Another choice is let legit to be a bit "smart",
if it detects there are two remotes naming origin and USER
(USER is github.user in ~/.gitconfig, if not set, falling back to login name),
then legit assumes origin is readonly and both publish/unpublish use USER as remote.
This also applies to sync, though the logic will be a bit complicated,
i.e. fetch from origin but push to USER.

Just some random thoughts.

@ParthS007
Copy link

@glehmann Are you done with the changes?
Can you please update the PR.
Thanks

@weakish
Copy link
Collaborator

weakish commented Sep 11, 2022

Another idea just occurred to me.

If legit detect there is a remote named foo, then publish foo will use foo as the remote.
Otherwise foo will be considered as a branch name, and publish foo will publish the branch to origin.

Strictly speaking, this is still a non backward compatible change,
but it probably will affect less issues to existing users
since few people use the same name for both the branch and the remote.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants