The Git/GitHub Questions, Answers and Howto Thread

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

Moderator: Committer

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

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

#181 Post by adrian_broher » Sat Oct 01, 2016 9:46 am

Morlic wrote:
MatGB wrote: All I wanted to do was remove a single commit from my branch.
I use

Code: Select all

rebase -i
for that. Drop the commit and pick everything else...
The general idea is okay and what I would suggest too, but he is using master as working branch.
Resident code gremlin
Attached patches are released under GPL 2.0 or later.
Git author: Marcel Metz

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

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

#182 Post by Ouaz » Tue Oct 11, 2016 3:41 pm

I encounter a new problem when trying to edit the FR stringtable with the GitHub web interface.

Usually, here's my process to edit the FR file (way quicker than doing it with Git):

- I enter the "Edit File" page (https://github.com/freeorion/freeorion/ ... les/fr.txt)
- In the textbox, I do a right-click then "Select All"
- Right-click again and I "Paste" my local FR file content
- Commit to master

But since today, when I "Select All", it also selects the line numbers, as a part of the file content!?
edit_file.gif
edit_file.gif (9.4 KiB) Viewed 738 times
So, when I check the modifications ("Preview Changes"), it says that there are 12986 additions (because obviously of the line numbers selection).

I updated my web browser (FF 49.0.1) but nothing changed.

Do you have the same problem?

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

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

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

#183 Post by Geoff the Medio » Tue Oct 11, 2016 4:44 pm

Happening for me as well. At least on a different file... if I try to select all on the huge stringtable page, it hangs firefox until I kill the task.

You can download the file by clicking "Raw", copy-paste it wherever, and then should be able to paste back into the text entry box. Having the line numbers doesn't seem to affect pasting.

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

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

#184 Post by Ouaz » Tue Oct 11, 2016 6:24 pm

Ok, thanks, it comes from GitHub then.

I found a quick fix though:

# On the "Edit" page (by clicking on the Pencil icon):

- Place the text cursor at the beginning of the file (first line, first character)
- CTRL+SHIFT+END (it will select all the file content -and still the line numbers-, and will place the cursor at the end of the last line)
- DEL on the keyboard
- It will delete everything, and place again the cursor on the first line
- CTRL+V the full file content copied from your local file
- Check the modifications with "Preview Changes"... everything is OK!

And voilà. ^^

Note: weirdly, it doesn't work by using the right-click context menu commands "Select All" then "Delete". It will delete only the first line... ??
I release every updated file under the CC-BY-SA 3.0 license.

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

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

#185 Post by Geoff the Medio » Fri Oct 14, 2016 10:07 pm

The merge button on the github website has changed... Should I start doing something other than merging with a merge commit?
Attachments
merge_pull_request.png
merge button
merge_pull_request.png (21.45 KiB) Viewed 712 times

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

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

#186 Post by Vezzra » Fri Oct 14, 2016 10:36 pm

Hm, I'd say "rebase and merge" (the new option) should be what we use normally - Marcel?

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

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

#187 Post by MatGB » Sat Oct 15, 2016 9:36 am

I think it'll depend on the PR—Squash and Merge is good for small(ish) PRs that contain, say, a "typo fix" commit or similar, I use it a lot as most of my reviews are for scripting stuff where a single commit that I've written in main is better.

I'm assuming the bottom rebase option will merge the commits in themselves without a merge message, so they'll each standalone and thus ideally need well written commit messages. And I'm also assuming the top option is merge-as-is, which I've never liked but is better if/when we merge in a fairly big project that has a lot of commits over time, a summary commit at the top explaining the main changes is easier, especially as users of Test releases need to rely on the recent commits list to know what they're meant to be looking for test wise.

So I'd say preference should be for squash and merge or rebase, but occasionally a merge commit would be better.
Mat Bowles

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

LGM-Doyle
Programmer
Posts: 219
Joined: Mon Feb 29, 2016 8:37 pm

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

#188 Post by LGM-Doyle » Sat Oct 15, 2016 4:37 pm

Merge and Commit for any PRs with more than one commit.
Rebase and merge for PRs that are already a single commit.

My reasons, are that the other options destroy information that is useful when debugging.

Squash and Merge
Squash and merge destroys context information in the multiple commits of a PR. If squashing the commits would make it easier to follow, then it should have been done in the PR before the merge.

As my current PRs make clear multiple commits make a PR easier to review. It also makes it easier to find and fix bugs after they are merged to master. It easier to find bugs if git-blame leads you to a focused commit where it is obvious what the original dev's intent was and how it is interacting poorly with the current code. Sometimes it is unclear because of subsequent changes in the code that couldn't be anticipated or caught in the original PR review.

Rebase and Merge
Rebase and merge destroys all of the branching information and folds all of the commits back into a linear commit history.
Rebase and merge makes the entire commit history look like old school CVS, giving up all of the post merge benefits of branches. It does not change the dates of the commits, so all commits of the merged branch and all other branches will be mixed in together.

github does not present the branching information prominently (or well), but many other tools do. To see the branching information in git bug click Graphs->Network and you can see where/when a PR was branched and where/when it merged. Again this is useful in debugging, because one PR is probably a series of related changes and seeing them in order allows you to see where things went wrong. Rebase and merge prevents this kind of debugging by destroying all of the branching information.

Rebase and merge is appropriate for small single commit PRs, like the commits that devs directly rebase and push onto master currently. The merge message would not have added any additional useful information to the commit record.,

Create a merge commit
This is the best option.

It keeps all of the branching information. Even if the original commits are over several weeks/months they are collected together. The arc of development is visible using most git tools and in github with Graphs->Network.

Having a merge message ties the whole PR together providing context for all of the changes as a set. We might consider asking contributors to include a merge message in their PR, or just use the initial PR message. Then the message is most like correct and not an additional burden on the merging dev.

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

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

#189 Post by Cjkjvfnby » Thu Sep 06, 2018 8:13 pm

As my current PRs make clear multiple commits make a PR easier to review. It also makes it easier to find and fix bugs after they are merged to master. It easier to find bugs if git-blame leads you to a focused commit where it is obvious what the original dev's intent was and how it is interacting poorly with the current code. Sometimes it is unclear because of subsequent changes in the code that couldn't be anticipated or caught in the original PR review.
I love squash and merge.

I usually write some code, doing some commits. After that, I test and add fixes. When it works I do self-review, fix some style and other issues.
History is full of commits with wrong intents and I don't think it is useful to see them. Yes, I can play with history and put all fixes to place where they should be, or squash it manually, but I don't want to waste time on it. Different people different coding style.

Squash and merge require one feature one PR. I can see all feature changes from one blame line. (IDEA annotate feature allow to see whole commit changes). I still can find PR for any commit, that was added via PR via GitHub UI interface.

My commit messages are not good. Lots of typos. But I can save some time and edit them in squash and merge interface.

For me, squash and merge is the time saver.
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