The Git/GitHub Questions, Answers and Howto Thread

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

Moderator: Committer

Post Reply
Message
Author
User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13586
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

The Git/GitHub Questions, Answers and Howto Thread

#1 Post by Geoff the Medio »

EDIT by Vezzra:
Split off from this thread.

Ok, questions and answers about how to use git and github begin to accumulate in several threads, so I decided to open this sticky thread as some means to collect all these posts here. I'm going to move postings that deal with this topic here, and invite everyone to continue related discussions here.

I could have used the thread Cjkjvfnby started for that, but I don't want to clutter it with various posts from various places, so I just put a link to his thread here: viewtopic.php?f=9&t=9363

One final word: Please, dear fellow devs, you really, really need to read up the basic git tutorials on the official git home page. Even if you (like me) are going to use a GUI git client, you need to understand the basic concepts and how git works. It's different from subversion, and it's important to understand these differences. You will spare yourself a lot of frustration.
/EDIT


I tried to create a branch, but I'm not sure if I did it correctly... It shows up as a branch in the freeorion account, but the master also seems to list the commits? Can anyone comment?

https://github.com/freeorion/freeorion/ ... port-Stuff
https://github.com/freeorion/freeorion/commits/master

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

Re: GitHub migration procedure

#2 Post by Cjkjvfnby »

Geoff the Medio wrote:I tried to create a branch, but I'm not sure if I did it correctly... It shows up as a branch in the freeorion account, but the master also seems to list the commits? Can anyone comment?

https://github.com/freeorion/freeorion/ ... port-Stuff
https://github.com/freeorion/freeorion/commits/master
How did you create branch? How did you push it?

Check .git/config in repo folder, after create branch and check again. upd. May be you push then you was in master?

Code: Select all

git checkout master
git checkout -b test_branch
# make commit
git push -u origin test_branch
Check branches on github.
Do cleanup

Code: Select all

git branch -d test_branch  # check output if branch was deleted
git push origin :test_branch  # pushing deleted branch on server will delete it from server
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: 13586
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: GitHub migration procedure

#3 Post by Geoff the Medio »

Cjkjvfnby wrote:How did you create branch? How did you push it?
Modified some files, right-clicked the FreeOrion folder and picked Git commit -> master. Picked some files, entered a log message. Repeated that a few times. Right clicked TortoiseGit -> Create Branch, specified a name, based on something (don't know what was picked). Then right clicked TortoiseGit -> Push..., picked some options (I have no idea, git is and the interface are ridiculously complicated) and clicked OK. Checked the github site, posted here.
Check .git/config in repo folder, after create branch and check again.
Check for what?

Code: Select all

[core]
	repositoryformatversion = 0
	filemode = false
	bare = false
	logallrefupdates = true
	symlinks = false
	ignorecase = true
	hideDotFiles = dotGitOnly
[remote "origin"]
	url = https://github.com/freeorion/freeorion
	fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
	remote = origin
	merge = refs/heads/master
I don't see anything about my branch in there, which might be part of the problem?
upd. May be you push then you was in master?
Maybe? I thought making a branch would push to the branch by default... presumably I've picked some wrong option somewhere in there, though?

git command line suggestions is useless for me...

wheals
Space Squid
Posts: 88
Joined: Sun Mar 24, 2013 3:56 pm

Re: GitHub migration procedure

#4 Post by wheals »

Since you made the commits before you made the branch, they ended up being in master as well as the branch (the branch being based off of your latest master). You'd have to make the commits after the branch, or (assuming http://tortoisegit.googlecode.com/git/d ... Commit.png looks around the same as the dialog you ran into?) checked that box saying "new branch" and made sure it was always being committed into there.
All my code and content provided herein or on GitHub is released under the GPL 2.0 and/or CC-BY-SA 3.0, as appropriate.

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

Re: GitHub migration procedure

#5 Post by Geoff the Medio »

wheals wrote:Since you made the commits before you made the branch, they ended up being in master as well as the branch (the branch being based off of your latest master). You'd have to make the commits after the branch, or ... checked that box saying "new branch" and made sure it was always being committed into there.
That somewhat makes sense. So if one has already committed to master locally, there's no way to move those commits to a new branch before pushing to remove / origin repository?

wheals
Space Squid
Posts: 88
Joined: Sun Mar 24, 2013 3:56 pm

Re: GitHub migration procedure

#6 Post by wheals »

Opening the new branch, which will now have all the commits you had on master, would be the first step.

On the command line, my next step would be to switch back to the master branch and wipe it clean (git checkout master && git reset --hard origin/master). I'm not sure how to do this on TortoiseGit; apparently there's a Reset dialog (https://tortoisegit.org/docs/tortoisegi ... reset.html) but I'm not seeing how to get to it. Maybe it's under the "Clean up..." menu option?
All my code and content provided herein or on GitHub is released under the GPL 2.0 and/or CC-BY-SA 3.0, as appropriate.

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

Re: GitHub migration procedure

#7 Post by Geoff the Medio »

Just made a new commit and push on the branch, and it appears to have only gone to the branch of the repository, as intended.

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

Re: GitHub migration procedure

#8 Post by Cjkjvfnby »

May be visualization of commit tree will help you to get in touch with git faster? (gitk is installed along with msysgit)
https://lostechies.com/joshuaflanagan/2 ... stand-git/
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 and Programmer Emeritus
Posts: 4768
Joined: Sat Sep 22, 2012 6:25 pm

Re: GitHub migration procedure

#9 Post by Dilvish »

Geoff the Medio wrote:git command line suggestions is useless for me...
You might not be used to working with the Windows command prompt, but it can be helpful sometimes. For SVN I found it most handy to work with a mixture of command line and gui. The basic install for TortoiseGit might not have put git into your system path, but I think that's easy enough to remedy. Here's a moderately recent post about setting up git and tortoisegit with command line ability; if you already did that setup this that page should point the way to using the git command line. If your setup was different and those steps don't work for you, then you could check your git executable location in tortoisesvn as shown on this tortoisegit help page, and then add that folder to your system path as discussed in this rather old post about tortoisegit.

If not using the special git-bash prompt as discussed in that first link, then for Windows 7 and earlier I get a standard command prompt from Start->Programs->Accessories (and then maybe another subfolder); this page has some instructions that are perhaps slightly more streamlined and includes instructions for Win8, plus good general info about the command line.
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

Mitten.O
Programmer
Posts: 255
Joined: Sun Apr 06, 2014 4:15 pm

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

#10 Post by Mitten.O »

To me TortoiseGIT embodies one of the greatest weaknesses of GUIs: To make the GUI able to do lots of things, you have to have lots of things in you face when you use the GUI. TortoiseGIT shows checkboxes for all the rarely needed and cryptic options of Git when you are trying to do the simple things. But it is a clone of TortoiseSVN so if you loved that, you may like TortoiseGit too.

The way I use Git is a combination of the command line, git gui and gitk. I cannot recommend git gui enough. It is a very simple tool that lets you do everything you need to create commits. It comes with all windows git installers I know of. You can launch it from the command line with "git gui". (From some installs it is also in the context menu of a git working copy). TortoiseGit needs piles and piles of complex dialogs and context menus for the basic uses cases git gui covers with a single window, because TortoiseGit tries to let you do everything.

The other gui tool I use is gitk. It too comes with git installers, you launch it with "gitk --all" . It lets you see existing commits in the branch DAG and check out and move branches. It is much like the SVN log.

For pushing, fetching and rebasing I use the command line, but TortoiseGit ot GitHub for windows are fine too, I suppose. I feel GitHub for windows has the Gnome syndrome, though. Aka. it tries to be too simple and look pretty to the detriment of actual usability.

On windows I make notepad++ my git editor. Make sure to specify at least -multiInst to make sure you get an independent window.

Code: Select all

git config --global core.editor "'C:/Program Files/Notepad++/notepad++.exe' -multiInst -notabbar -nosession"
BTW: An SVN update is semantically closer to a fetch+rebase than a pull. Understanding that may help SVN people grok the concepts.
Any code by me in this post is released under GPL 2.0 or later.

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

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

#11 Post by Geoff the Medio »

Mitten.O wrote:To me TortoiseGIT embodies one of the greatest weaknesses of GUIs: To make the GUI able to do lots of things, you have to have lots of things in you face when you use the GUI. TortoiseGIT shows checkboxes for all the rarely needed and cryptic options of Git when you are trying to do the simple things. But it is a clone of TortoiseSVN so if you loved that, you may like TortoiseGit too.
That seems like a problem with poorly designed GUIs... there should be options, but they don't all need to be immediately visible. I'm certainly not liking TortoiseGit as much as TortoiseSVN; the latter has a dramatically simpler interface, and the former has dozens of droplists and buttons and check and lists on every dialog. Your comment gives me hope that perhaps it's partly due to the design of TortoiseGit that git is seeming to be so needlessly complicated to do anything.

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

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

#12 Post by Vezzra »

Mitten.O wrote:An SVN update is semantically closer to a fetch+rebase than a pull. Understanding that may help SVN people grok the concepts.
Yep, although, for that to really grasp you first need to familiarize yourself at least basically with what "fetch" and "rebase" is. Otherwise, well, you won't get past "huh?".

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

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

#13 Post by Vezzra »

Geoff the Medio wrote:Your comment gives me hope that perhaps it's partly due to the design of TortoiseGit that git is seeming to be so needlessly complicated to do anything.
Git is a bit confusing and seemingly complicated at first, the main problem really is to get past the initial confusion. I can only repeat over and over, dig through the tutorials. That helped me more than anything else to get started.

Once you get the hang of it, git is really nice and powerful IMO. I begin to understand why people who are used to it are having such a hard time if they have to put up with subversion... ;)

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

Re: GitHub migration procedure

#14 Post by Geoff the Medio »

Edit by Vezzra: This post is a reply to this one. Moved it and follow-up replies here.
adrian_broher wrote:
Geoff the Medio wrote:What does having a tag mean if the branch containing the commit that was tagged is deleted...?
I don't understand your question, sorry.
You propose to delete the release branch, but then have a tag or link to a particular commit for a release. But if the release commit is on the release branch, which was deleted, how can you link to or refer to it, since the release commit (at least for v0.4.4) is not merged back to trunk, so only exists on the (deleted) branch?

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

Re: GitHub migration procedure

#15 Post by Vezzra »

Geoff the Medio wrote:What does having a tag mean if the branch containing the commit that was tagged is deleted...?
AFAIK deleting a branch in git just deletes the "branch marker" pointing to the latest commit of the branch. This doesn't change anything about the commit history. The tag won't be affected by deleting the branch, and still point to the same commit as before.

Post Reply