best/safest practice for interacting with github
Kevin Bullock
kbullock+mercurial at ringworld.org
Mon Nov 18 19:48:38 UTC 2019
> On Nov 18, 2019, at 11:27, Ernie Rael <err at raelity.com> wrote:
>
> Greetings,
>
> It's been over 5 years, but I am again going to work with NetBeans source, do some pull requests... It is now on github. I've never used git. I used hggit to clone the repo; then made a github fork, moved my path to my fork. Cool, so far seems OK.
>
> Now I'm looking at the NB docs and see stuff like "then do 'git config --global user.name "John Doe"' " and also a cmd for email. The 'git remote add upstream ...' so I can submit PULL REQUESTS certainly has me confused.
You can use your clone directly to contribute. The Mercurial equivalent of the `git remote add upstream ...` command they list is adding another entry under [paths] in your .hg/hgrc (the config file in the your local clone). So you'd end up with something like:
[paths]
default = git+ssh://git@github.com/yourusername/netbeans.git
upstream = git+ssh://git@github.com/apache/netbeans.git
And then you can pull from either:
$ hg pull # or `hg pull default` -- pulls from your fork on GitHub
$ hg pull upstream # pull from the canonical repo
When the NetBeans instructions tell you to create a Git _branch_, you'll want to create a Mercurial _bookmark_. You can then do your work and commit, then push that bookmark to your fork and open a pull request. In other words:
$ hg pull upstream
$ hg update master
$ hg bookmark mybranch # equiv. to `git checkout -b mybranch`
...make your changes...
$ hg commit -m '[NETBEANS-XXXX]'
$ hg push -r mybranch # equiv. to `git push [-u] origin mybranch`
Note that hg-git currently has some warts around rewriting history locally -- there are workarounds but it's not a smooth experience. As long as you don't rewrite (i.e. rebase, amend, histedit, etc.) any changes you've already pushed, you'll be okay.
> I'm considering using git to clone my github fork to local, then point my current hggit clone to the local github clone. The idea is that I might want to do stuff (NB docs) locally before pushing to github. Is this needed and/or a good idea?
Nah, as I've described above you can pretty well eliminate the extra local clone -- after all that's what hg-git does internally anyway!
> -ernie
>
> PS. I recall years ago seeing somewhere about running git and hg commands both in the same clone, but that seems fraught with danger.
Yeah, I'd recommend against trying that.
pacem in terris / мир / शान्ति / سَلاَم / 平和
Kevin R. Bullock
More information about the Mercurial
mailing list