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: 480
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: 3188
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: 627
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/macmodrov
[...] 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: 3188
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: 12802
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.

Post Reply