So I’m new to github. And not gonna lie, I feel a little ashamed about it. To me it’s always been one of those things that only the super impressive graduate students know how to use and navigate, but it just never stuck for me. Hence my embarrassingly grey contribution array.


Fetching, pushing, pulling, it’s all been a little difficult to keep track of. I suspect it’ll get easier as I keep using it, but for now I should probably write down some instructions for myself to reference back to. Like how to properly update my pull requests!
So here’s how it went: I submitted a PR, later saw a change I needed to make, made a new commit, got some comments on things I should/needed to change, made some more commits, and suddenly I had a whole list of small-change commits that I needed to squash. By the way, I love that it’s called squashing. Really captures what’s going on.
Ideally you would just fetch, edit, add, commit, squash, and push right? Well git does not care about your happiness. It will help you collaborate and ease version control with reluctance.

Specifically, I had some struggles rebasing. I kept getting super long lists of commits I didn’t make, commits I did make but weren’t showing up, merge conflicts, all that fun stuff. So I took the tried-and-true IT approach: “Did you try turning it on and off again?”. Otherwise known as “Forget this branch, I’m starting over!”.
Future-self, here’s how to edit PRs in a way that works for you:
>>> git fetch astropy
>>> git fetch tcjansen
>>> git checkout --track tcjansen/<branch>
Make whatever changes to <file>
>>> git add <file>
>>> git commit -m "useful message here"
At this point if you don’t make any more changes you don’t have to rebase. But if you do make changes, do the following:
>>> git rebase -i astropy/master
In the editor window that pops up, “pick” a commit, and “squash” the remaining commits by replacing the “pick” command with “squash”. Once you save the document, a new editor window will come up, in which you want to just delete the commit messages of the ones you squashed. You can also edit the first commit message if you want. Then push it back to your remote repo:
>>> git push -f tcjansen # use the force young padawan
Now I’m going to be the super impressive graduate student gosh dang it!

