Jump to content

Help with git[hub]


HebaruSan
 Share

Recommended Posts

Greetings, esteemed and beloved modders. I'm trying to figure out how to do something with git, and I'm posting here because it's KSP-mod-related and because so many mods are on github that there must be a high degree of git expertise here; this may be a trivial question for some of you. I've been reading git tutorials and guides and so on, which so far has only made me feel like I have some sort of git-specific learning disability; I still have to rely on googling "how to do <svn command> in git" and praying that my situation is close enough to what the resulting blog post is doing.

What I've done so far:

  1. Clone the KerbalEngineer github onto my local disk sometime around September 2015 (version 1.0.18.1 according to the old ASSEMBLY_VERSION, though its changes are subsumed into 1.0.19.1 in the latest changelog)
  2. Play around with it for a while locally (to add a US customary units option) without running any further git commands
  3. Let it sit for a while, so I ended up with uncommitted changes to an old version
  4. Finally create a github account within the last few weeks
  5. Fork the main KER repo onto my github account (so, ~9 months after my initial clone)
  6. Commit my changes to my local repository (I think? It shows up in git log, anyway)
  7. Change the remote of my local copy from the originally cloned main KER branch to my own forked branch (I think?)
  8. Possibly some other things; regrettably I did not take careful notes while researching and experimenting
  9. I don't think I stashed anything

I'd like to bring my changes up to date and clean them up enough to submit a pull request (if that's how it works?). Current state:

  • git diff --cached shows the changes that everyone else committed since September that don't conflict with my changes (which makes me think I must have staged those after a merge, if that's a thing)
  • git diff shows BuildAdvanced.cs (whole file changed? but I don't remember what I did to it, so I'd like a better diff) and Units.cs (my core changes)
  • git status says I've staged everything but those two files, so presumably I need to resolve conflicts on them:
    On branch master
    Your branch and 'origin/master' have diverged,
    and have 1 and 38 different commits each, respectively.
      (use "git pull" to merge the remote branch into yours)
    You have unmerged paths.
      (fix conflicts and run "git commit")
  • Some of my changes are in neither git diff nor git diff --cached, but are present in the working copy; I hypothesize that these are the things I changed that didn't have any conflicts. So they're already committed, even though they depend on changes that aren't committed yet?

I don't think I want it to be in this state; I want to see my changes only in a diff, and all together in one diff only, with everyone else's changes already incorporated, as if I had made my changes originally on the current branch. Is that possible? If so, how do I get there from here? Am I supposed to "cherry pick" my local commit? If not, what's the better way? This has got to be a fairly common use case, if not the most common (clone/fork a project from github, commit/push changes, submit a pull request), so I feel like I'm missing something (scratch that, I'm sure I'm missing plenty in general about git).

Also, how do I keep my github fork up to date in the meantime? I don't want to get out of sync and have to do this all over again.

Thanks in advance for any help! I may have left out some relevant info, so please name any additional commands to run and I'll post the output.

(A humble plea: Please don't refer me to yet another git tutorial unless it's about this exact specific question; as I've said, I've already been reading them and they just aren't helping.)

Link to comment
Share on other sites

I'm in a similar boat with github, but I haven't done much reading... yet. I too find it somewhat confusing, but I've been using a program called GitKraken to poke around the repo stuff. I'm not sure if that's the way to go about it, I just like the visual manner it presents things in. Why GitKraken? No real reason...it's free, cross platform, seemed reasonably up to date, and 'cuz Kraken. Not sure how you're going about it, but maybe try something similar?

Honestly, you're ahead of where I'm at, so that's the best advice I can give you (which admittedly isn't the greatest).

Good luck.

Link to comment
Share on other sites

So, assuming that you already have a GitHub account:

  1. Log in to your git account via the web "client".
  2. Browse to the official KER git repository (or, generally, any other git repository).
  3. Fork the repository to your own account.
  4. Get a git client of your preference (there is a lot of them with various features and limitations).
  5. Log in to your local git client and clone the repository locally.
  6. Open the command line (via the local git client) and update the local version (if out-of-date) via "git fetch KerbalEngineer" and "git merge KerbalEngineer/master".
  7. Create a new branch via "git checkout -b <NameOfYourBranch>".
  8. Make all the changes that you want to the source code/assets.
  9. The git client will now "see" the changes and prompt you to commit the changes to the branch (along by displaying the additions/deletions for reviewing).
  10. Commit the changes and issue a "git push" for the changes to be pushed and stored to your git repository.

The git repository will now include the base KER (untouched) and a new branch of that repository (NameOfYourBranch) as a subset of the first one. After that you are free to re-review the changes and create a Pull Request if you want them to be included to future official releases*.

* Cybetek must also review and accept the changes before they are merged into the official KER repository.

I hope that this helps!

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...