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
Cjkjvfnby
AI Contributor
Posts: 539
Joined: Tue Jun 24, 2014 9:55 pm

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

#211 Post by Cjkjvfnby »

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
Oberlus
Cosmic Dragon
Posts: 5704
Joined: Mon Apr 10, 2017 4:25 pm

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

#212 Post by Oberlus »

Best way to make PRs that depend on other not-merged PRs?


Say I have PR Feature-1 waiting for approval, and I want to start working on another PR Feature 2 that depends on "Feature 1", and eventually pushing it before Feature-1 was merged. What is the preferred way to make the branching, commits and push to minimise merge conflicts and keep a tidy commit history?

Can I just do

Code: Select all

git checkout Feature-1
git checkout -b Feature-2
// hack hack hack
git commit -a -m "This is Feature-2, follow up of Feature-1"
git push origin Feature-2
?

(edit)

User avatar
em3
Vacuum Dragon
Posts: 630
Joined: Sun Sep 25, 2011 2:51 pm

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

#213 Post by em3 »

Well, yeah. Technically you can. Note, that any PR from Feature-2 to upstream/master will contain also commits from Feature-1. If Feature-1 is merged before Feature-2 it won't be a problem, as the commit is the same (same hash, same parents) and Feature-2 PR will no longer include Feature-1 changes in its commit list (as they will already have been in master). If Feature-2 is merged before Feature-1, Feature-1 PR becomes a no-op, because Feature-2 will have already merged all changes from Feature-1 into master.
https://github.com/mmoderau
[...] for Man has earned his right to hold this planet against all comers, by virtue of occasionally producing someone totally batshit insane. - Randall Munroe, title text to xkcd #556

User avatar
Oberlus
Cosmic Dragon
Posts: 5704
Joined: Mon Apr 10, 2017 4:25 pm

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

#214 Post by Oberlus »

Then... Feature-2 PR could indicate that it supersedes Feature-1 when pushed to master (if Feature-1 wasn't merged)?

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

#215 Post by Geoff the Medio »

The main problem with those pull requests that include stuff from other pull requests is that it's harder to review the later pull request with the older stuff also in the changes.

Noting in the description that another pull request is included or that the latter one depends on the former is a good practice, though, I think.

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

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

#216 Post by Cjkjvfnby »

One non-obvious feature of GitHub is review requests after feedback.

When a person approves/comments/requests changes his name is still present on the review page, but actually, the review request was fulfilled. To request a review again you need to click on rotation arrows near the reviewer name. This feature gives you the flexibility to push multiple times before requesting the review again.
not_requested.png
not_requested.png (13.3 KiB) Viewed 1499 times
GitHub has a dashboard for review requests, so you could easily check what should you review next.
https://github.com/pulls/review-requested.
no_review.png
no_review.png (60.26 KiB) Viewed 1499 times
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
Cjkjvfnby
AI Contributor
Posts: 539
Joined: Tue Jun 24, 2014 9:55 pm

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

#217 Post by Cjkjvfnby »

If you want to checkout a branch from another fork you need to add another remote.

For example, I want to get Grummel7s branch AIwithPolicies on my machine.

Code: Select all

git remote add Grummel7 https://github.com/Grummel7/freeorion.git
  • Grummel7 is a name that will be shown in your console, you could put any, I usually use user name.
  • https://github.com/Grummel7/freeorion.git is repo address from GitHub page. Use ssh or HTTP. You could always check which method you use by checking origin on the output of git remote -v

Code: Select all

git fetch Grummel7
Fetch all branches from remote.

Code: Select all

git checkout AIwithPolicies
Checkout branch, by its name.

You could even push changes to this branch, but you need to ask about access from the repo owner first.
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