Syncing a fork with GitHub Desktop?

Talk about anything and everything related or unrelated to the FreeOrion project, especially Strategy Games.

Moderator: Oberlus

Post Reply
Message
Author
User avatar
Ouaz
Dyson Forest
Posts: 232
Joined: Wed Aug 13, 2014 7:21 pm
Location: France

Syncing a fork with GitHub Desktop?

#1 Post by Ouaz »

I installed GitHub Desktop because the Web interface (which I exclusively used) lacks two features:

- I can't update my FO fork (in order to be synced with FO main repo)
- I can't add images into my fork (only text files) in order to create a PR.

As I'm very bad with command lines, I thought that GitHub Desktop would be the solution... But there's something I totally don't understand concerning the Sync feature.

I clone my fork of Freeorion project.

So I have:

- my local repo ("master")
- the "remote" repo (my fork on GitHub)
- the upstream repo (freeorion/freeorion) automatically linked.

I can update my local repo from the upstream repo. That's OK, the two repositories are synced.

But after that, if I want to sync my local repo and the remote repo (so my fork will be identical to my local repo), it creates automatically a new commit (both on my local repo and on my fork) for the merge (.

So, both my local repo and my fork are one commit ahead the Freeorion main repo. And if I want to make a new PR, it contains this useless commit too.

Is it not possible to update the fork from the local repo, like the local repo is updated from the FO main repo?

Thanks.
I release every updated file under the CC-BY-SA 3.0 license.

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

Re: Syncing a fork with GitHub Desktop?

#2 Post by MatGB »

It is, but for some reason the command needed isn't there as a basic feature in most of the GUIs.

Assumption: you're using Windows and you're using the GitGUI client (which is what I use(d) on Windows).

You can add commands to the menu, I forget which menu option it is (because I'm on Linux with different software) but I think it was one of the furthest right menus on the topbar, and the command you need is "git rebase master", this will rebase your clone from the master branch and then put your work at the top.

It's possible this might not work, you need to tell it that 'master' is the name of the main repo, or simply store 'git rebase https://github.com/freeorion/freeorion'. If it's not updating properly, then 'git fetch master' or 'git fetch https://github.com/freeorion/freeorion' should work, then rebase again.

Once you've stored it in as a command it should then be possible to do it multiple times without retyping it.

I was also terrible with command line, but I learnt as many git commands as I could because I'm switching systems fairly regularly and remembering a few words to type is easier than leaning completely different buttons to press in radically different GUIs, especially when some of the commands aren't there, despite them being obvious ones.

I hope that helps.

(we don't like using git pull because of all the extra commits it creates, plus it then puts your work amongst other commits which makes it harder to spot new stuff in trunk)
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
Ouaz
Dyson Forest
Posts: 232
Joined: Wed Aug 13, 2014 7:21 pm
Location: France

Re: Syncing a fork with GitHub Desktop?

#3 Post by Ouaz »

Thanks for the answer.

After having read your post numerous times (something like 20 times ^^), I think I begin to understand.

In GitHub Desktop, I can open the command console by right-clicking on the local repo name ("Open in Git Shell"), then I can add commands lines (like "git remote -v" in order to know what are the names and url of each repository), if it's that you mean by "adding commands to the menu".

To be short:

I fetch changes from freeorion/freeorion (upstream) and merge those changes into my local repo ("master"), so the two repositories are synced.
> In GitHub Desktop, it just requires to click on "Update from [freeorion]/freeorion/master" button. Local and Upstream are now synced (timeline graphics are on par).

Then I want to push those changes to my fork on GitHub.com ("git push origin master" ?)
> In GitHub Desktop, it just requires to click on "Sync" button (if I understand well).

But after that, instead of my fork being synced with my local repo and the upstream repo, my fork master branch is 1 commit ahead freeorion:master, whereas it should display "This branch is even with freeorion:master".

Maybe I'm doing something wrong, or I miss something... Whatever, I will come back tomorrow with some annotated screenshots to better explain. :oops:

Thanks again.
I release every updated file under the CC-BY-SA 3.0 license.

User avatar
Ouaz
Dyson Forest
Posts: 232
Joined: Wed Aug 13, 2014 7:21 pm
Location: France

Re: Syncing a fork with GitHub Desktop?

#4 Post by Ouaz »

Phew, finally did it, and finally understood all you were saying in your post. :D

The problem came from I thought that the "Update from freeorion/master" button in GitHub Desktop did a "fetch" then a "merge" in my local repo, but like you said, it did a "pull", creating an extra commit, which was pushed to the origin repo (my fork on Github) afterwards.

When I open GitHub Desktop, the "fetch" command is automatically done, I just have to do "git merge freeorion/master" when I'm on my local repo ("master").

Then, if I click on the "Sync" button, the changes are sent correctly to my fork on GitHub. It seems to be equal to "git push origin master", I don't know, but whatever, it works now and my fork is synced without extra commits.

Note: when I do "git merge freeorion/master", there is a warning message: "refname freeorion/master is ambiguous". Is this normal?

Thanks again, you were right, once that's understood, it's not so complicated. :mrgreen:
I release every updated file under the CC-BY-SA 3.0 license.

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

Re: Syncing a fork with GitHub Desktop?

#5 Post by adrian_broher »

Ouaz wrote:Note: when I do "git merge freeorion/master", there is a warning message: "refname freeorion/master is ambiguous". Is this normal?
No it isn't. A refname is a symbolic and human readable name to an actual commit, and can be a branch name, a tag, a branch on a remote, …. For example: if you happen to create a local branch called 'freeorion/master' (yes, branch names can contain slashes, in fact you can organize them in folders) and you happen to name the upstream repository remote 'freeorion' it would happen that there is a remote branch called 'freeorion/master' both would have the same name therefor would be ambiguous, because git doesn't know if you meant the local branch or the remote branch when executing an operation. If you know that wasn't intendent by you you can rename the ref by giving its canonical name. Just execute 'git show-ref' to see all available refs. You can delete it with 'git update-ref -d <canonical name>', where the canonical name is the path to the offending ref startings with 'refs/' or rename it with 'git branch -m <oldbranch name> <newbranch name>'.
Resident code gremlin
Attached patches are released under GPL 2.0 or later.
Git author: Marcel Metz

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

Re: Syncing a fork with GitHub Desktop?

#6 Post by Geoff the Medio »

I gave up on using Github for Windows due to issues such as this, and the general inability to control what it's doing in terms of pulling/fetching or pushing when clicking the sync button. Instead I've been using TortoiseGit, which lets me do most of what I need, though still with occasional mistakes / unintended results (mainly when trying to work with branches instead of committing directly to master always).

User avatar
Vezzra
Release Manager, Design
Posts: 6095
Joined: Wed Nov 16, 2011 12:56 pm
Location: Sol III

Re: Syncing a fork with GitHub Desktop?

#7 Post by Vezzra »

As Geoff said, GitHub Desktop is not a very good GUI for git. Apparently it has a lot of issues. The two GUIs I'm using and can recommend are SourceTree and SmartGit. IMO SourceTree is clearer and simpler to use, while SmartGit seems a bit more powerful (e.g. built-in conflict solver, which SourceTree lacks). Both are free for personal (non-commercial) use and available for Windows, Mac OSX and Linux.

Post Reply