The Git/GitHub Questions, Answers and Howto Thread

Programmers discuss here anything related to FreeOrion programming. Primarily for the developers to discuss.

Moderators: Committer, Committer

Message
Author
User avatar
MatGB
Creative Contributor
Posts: 3310
Joined: Fri Jun 28, 2013 11:45 pm

Re: The Git/GitHub Questions, Answers and Howto Thread

#106 Post by MatGB » Thu Jul 02, 2015 10:24 pm

A memo post

Code: Select all

git fetch --all
is needed to update your local list of the branches on the remote, you can't switch to a new remote branch unless you ensure your copy knows it exists. So if another Dev has a shiny new feature in a branch for testing, you need to make sure your copy of git knows that branch is there before you spend half an hour trying to figure out why you can't switch to it, merge from it, pull from it, etc.
Mat Bowles

Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.

User avatar
adrian_broher
Programmer
Posts: 1082
Joined: Fri Mar 01, 2013 9:52 am
Location: Germany

Re: The Git/GitHub Questions, Answers and Howto Thread

#107 Post by adrian_broher » Fri Jul 03, 2015 7:25 am

MatGB wrote:A memo post

Code: Select all

git fetch --all
is needed to update your local list of the branches on the remote, you can't switch to a new remote branch unless you ensure your copy knows it exists. So if another Dev has a shiny new feature in a branch for testing, you need to make sure your copy of git knows that branch is there before you spend half an hour trying to figure out why you can't switch to it, merge from it, pull from it, etc.
Correction:

Code: Select all

git fetch
Fetches by default from remote 'origin'. However:

Code: Select all

git fetch --all
Fetches from all remotes configured for the repository.

See also `man git-fetch` or web version of said manual.

P.S.

I just read in the manual that you also can define groups. For example you could set up a group of remotes, that should be updated together. This would be interesting for fetching from all trusted developers in a team or so.

Code: Select all

$ cd <fo repository>
$ git remote add geoff git@github.com:geoffthemedio/freeorion.git
$ git remote add adrianbroher git@github.com:adrianbroher/freeorion.git
$ git remote add vezzra git@github.com:Vezzra/freeorion.git
$ # some more remotes
$ git config remotes.team 'geoff adrianbroher vezzra <some more remote names>'
$ git fetch team
Resident code gremlin
Attached patches are released under GPL 2.0 or later.
Git author: Marcel Metz

User avatar
MatGB
Creative Contributor
Posts: 3310
Joined: Fri Jun 28, 2013 11:45 pm

Re: The Git/GitHub Questions, Answers and Howto Thread

#108 Post by MatGB » Fri Jul 03, 2015 11:40 am

Well, just simply using fetch wasn't getting me anywhere, my branch list refused to admit there was a new branch there, but fetch --all got it. The team thing is interesting though, that has the potential to be very useful.
Mat Bowles

Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.

User avatar
Dilvish
AI Lead, Programmer
Posts: 4768
Joined: Sat Sep 22, 2012 6:25 pm

Re: The Git/GitHub Questions, Answers and Howto Thread

#109 Post by Dilvish » Fri Jul 03, 2015 3:59 pm

MatGB wrote:Well, just simply using fetch wasn't getting me anywhere, my branch list refused to admit there was a new branch there, but fetch --all got it.
Your local repo is perhaps set up with origin being your github fork, and the main FO repo as 'upstream'? (That's how I have mine.) So you would need to do 'git fetch upstream' (or 'git fetch --all' like you've been doing) for your repo to be made aware of a new branch in the main repo.
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

User avatar
MatGB
Creative Contributor
Posts: 3310
Joined: Fri Jun 28, 2013 11:45 pm

Re: The Git/GitHub Questions, Answers and Howto Thread

#110 Post by MatGB » Fri Jul 03, 2015 4:20 pm

Actually, I don't think I've touched my github fork at all since I switched to Linux, I'm doing everything from main, occasionally creating a branch to test something.
Mat Bowles

Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.

User avatar
Cjkjvfnby
AI Contributor
Posts: 460
Joined: Tue Jun 24, 2014 9:55 pm

Re: The Git/GitHub Questions, Answers and Howto Thread

#111 Post by Cjkjvfnby » Fri Jul 03, 2015 4:43 pm

MatGB wrote:Actually, I don't think I've touched my github fork at all since I switched to Linux, I'm doing everything from main, occasionally creating a branch to test something.
Does --all have sence in that case?

You can use git pull -p it is shortcut to git fetch && git pull
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 12457
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: The Git/GitHub Questions, Answers and Howto Thread

#112 Post by Geoff the Medio » Sun Jul 12, 2015 9:51 pm

I just did... something... Possibly pushed nonsensical changes to a bunch of branches I didn't intend to. Seems to have generated a bunch of commits that merged branches into themselves?

Edit: Possibly it created branches in the freeorion repository that were originally in other people's repositories?

User avatar
MatGB
Creative Contributor
Posts: 3310
Joined: Fri Jun 28, 2013 11:45 pm

Re: The Git/GitHub Questions, Answers and Howto Thread

#113 Post by MatGB » Sun Jul 12, 2015 10:55 pm

Geoff the Medio wrote:I just did... something... Possibly pushed nonsensical changes to a bunch of branches I didn't intend to. Seems to have generated a bunch of commits that merged branches into themselves?

Edit: Possibly it created branches in the freeorion repository that were originally in other people's repositories?
That's what it looks like, I can't see any of the things you've done actually in trunk itself, were you testing stuff on your home machine?
Mat Bowles

Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 12457
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: The Git/GitHub Questions, Answers and Howto Thread

#114 Post by Geoff the Medio » Sun Jul 12, 2015 11:01 pm

MatGB wrote:...I can't see any of the things you've done actually in trunk itself, were you testing stuff on your home machine?
I didn't do anything new in the trunk. I was creating a new branch and attempting to push it so that I could make a new pull request, which succeeded. But apparently I clicked the wrong option in the push dialog and pushed every branch I have locally, which includes various old branches from pull requests that I probably don't have write access to.

User avatar
MatGB
Creative Contributor
Posts: 3310
Joined: Fri Jun 28, 2013 11:45 pm

Re: The Git/GitHub Questions, Answers and Howto Thread

#115 Post by MatGB » Mon Jul 13, 2015 12:00 am

Geoff the Medio wrote:
MatGB wrote:...I can't see any of the things you've done actually in trunk itself, were you testing stuff on your home machine?
I didn't do anything new in the trunk. I was creating a new branch and attempting to push it so that I could make a new pull request, which succeeded. But apparently I clicked the wrong option in the push dialog and pushed every branch I have locally, which includes various old branches from pull requests that I probably don't have write access to.
That makes sense, I, um, nearly did that myself last week and it would be even easier to use in Git GUI on Windows (I did it on my Github repo several times).

It's not, in any way, a problem, you've basically copied your local working copies to the main repo, we just need tog et them deleted (and you probably want to delete the branches from your machine if you don't need them anymore). Anyone that cloned since you did it will have some obsolete stuff but that's a minor annoyance (as far as I know, I expect someonewill explain if I'm wrong).

I can't figure out how to push just one branch from my machine to the main project repo, I'd like to but it doesn't seem as easy as I'd hoped and I don't really need it (although I will after Release, I've got a few Projects in mind that'll need help).

Go here: Branches · freeorion/freeorion they look like they';re easily deletable and you won't have done anything to the originals, just your copies on your machine.
Mat Bowles

Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.

User avatar
Dilvish
AI Lead, Programmer
Posts: 4768
Joined: Sat Sep 22, 2012 6:25 pm

Re: The Git/GitHub Questions, Answers and Howto Thread

#116 Post by Dilvish » Mon Jul 13, 2015 12:56 am

Ya, I just deleted the extra branches from freeorion/freeorion
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

User avatar
adrian_broher
Programmer
Posts: 1082
Joined: Fri Mar 01, 2013 9:52 am
Location: Germany

Re: The Git/GitHub Questions, Answers and Howto Thread

#117 Post by adrian_broher » Thu Jul 16, 2015 7:56 am

MatGB wrote:I can't figure out how to push just one branch from my machine to the main project repo, I'd like to but it doesn't seem as easy as I'd hoped and I don't really need it (although I will after Release, I've got a few Projects in mind that'll need help).

Code: Select all

git push <name of remote> <name of local branch>:<name of remote branch> [<name of local branch>:<name of remote branch>]
so if the remote 'upstream' points to the main project repository and you want to push the local 'foo' branch to the remote 'bar' branch:

Code: Select all

git push upstream foo:bar
or, if your remote branch has the same name or should have the same name as local branch 'foo':

Code: Select all

git push upstream foo
Resident code gremlin
Attached patches are released under GPL 2.0 or later.
Git author: Marcel Metz

User avatar
Cjkjvfnby
AI Contributor
Posts: 460
Joined: Tue Jun 24, 2014 9:55 pm

Re: The Git/GitHub Questions, Answers and Howto Thread

#118 Post by Cjkjvfnby » Thu Jul 16, 2015 8:01 am

adrian_broher wrote:
MatGB wrote:I can't figure out how to push just one branch from my machine to the main project repo, I'd like to but it doesn't seem as easy as I'd hoped and I don't really need it (although I will after Release, I've got a few Projects in mind that'll need help).

Code: Select all

git push <name of remote> <name of local branch>:<name of remote branch> [<name of local branch>:<name of remote branch>]
If you plan to push more changes to this branch you can add '-u, --set-upstream set upstream for git pull/status' this will allow to do git push and git pull without arguments at next time.
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

User avatar
Dilvish
AI Lead, Programmer
Posts: 4768
Joined: Sat Sep 22, 2012 6:25 pm

Re: The Git/GitHub Questions, Answers and Howto Thread

#119 Post by Dilvish » Thu Jul 16, 2015 10:41 am

MatGB wrote:I can't figure out how to push just one branch from my machine to the main project repo, I'd like to but it doesn't seem as easy as I'd hoped
With SmartGit that is just a simple rightclick on the branch.
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

User avatar
Dilvish
AI Lead, Programmer
Posts: 4768
Joined: Sat Sep 22, 2012 6:25 pm

Re: The Git/GitHub Questions, Answers and Howto Thread

#120 Post by Dilvish » Wed Jul 22, 2015 12:36 am

It seems like our forum server just crashed and lost some history. It wouldn't respond for a while, and now the posts I am responding to seem gone, and I don't see them moved to some other thread...
Cjkjvfnby wrote:You way is impossible for GUI users.
Only for users of inadequate GUIs. I generally use pretty much the same process adrian_broher talked about, and SmartGit supports it wonderfully. If there are no conflicts, combining tiny related commits into a more medium sized commit only takes seconds, and can help make it easier to really review the set of changes. As we've talked about before, if there are conflicts then clearing them with rebasing makes a clearer product for other people than just merging. I know you've messaged me about this process you do with merging and them making a diff and then applying that, and if that's what you did for your PR #221 then I'll say the end product looks ok so long as it makes sense to squash it all down to a single commit, but in that case it would have been even simpler to first squash it where it was, and then rebase that to current master. Much fewer steps than what you talked about.
Making good history take too much time and does not improve process.
How can you keep saying this? Especially when there are plenty of articles talking about the value of a good git history and your teammates (including one who seems quite experienced with this, adrian/Marcel) say they want the benefit of that good history. You are kind of seeming like the guy who hates commenting, and so just does a few trivial comments here and there, and then says that since his comments are useless, that writing good comments "does not improve process".

@adrian_broher -- the one area where I at least nominally differ from your process is the step that (to the best of my recollection) was something like "hard reset master to feature". I generally just cherry pick the commits from feature to master, which is just a couple clicks and a few seconds in SmartGit. There is also one of its rebasing functions that could be used in this situation, but I never use that one. It seems to me like the end result is likely to be the same (at least in this situation that we're discussing) as your hard reset step, but am I overlooking something?


**edit** Cj, also, if the merge process you told me about via email, with merging and resolving conflicts and making a diff and then applying that to master, is what you did for your PR# 221, then I'll say that the final product is generally fine, to the extent that it's fine to have the feature all squashed into a single commit, but in that case it also seems to me it would have been much simpler to simply squash the commits where they were, and then rebase that resulting commit to master.
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

Post Reply