Tuesday, April 12, 2016

A year of Github

So I made my first commit to GitHub a year ago. It wasn't much, but the daily streak eventually helped me to REALLY get going.

Since then, I've

* made documentation and code changes to Trizbort
* made repositories for my 2012-2015 IFComp games
* also merged in my 2013 Spring Thing game with 2012
* created a miscellaneous files archive for all kinds of things
* copied over some of my old RPG map creation files
* made 1000+ changes
* started an almost 5 month + daily streak

This is a lot, and I can't call myself a GIT wizard. I just know the basic commands. In fact, I have a cheat sheet for some of them below the cut.

So why am I posting this to planet-if?

Because many people I know have questions. They wonder how to get started. They think it'll be impossible.

But I think the way to start is to say, okay, I want some sort of backup so my files don't get lost. I'll push story.ni to it. I don't care about anything else. Maybe I'll report an issue. And then build from there. That's how I did it. Just pushing trivial changes, maybe even starting with something silly like an EctoComp entry where I needed to clear up typos.

The drawback is that I've neglected bitbucket, which doesn't have that small nudge. But I've done well with modifying my current Spring Thing game as well as my possible IFComp 2016 game.

My cheat-sheet is below. I'm not worried about too much else. Clone, commit and push are all you need to know. I even forget the difference between clone and fetch--but the nice thing is, you can't ruin too much. So go ahead. Make a blank project. Poke around. Start with small changes. You might be happy and impressed what you've come up with.




To get a repository:
git clone https://github.com/andrewschultz/[name].git
git clone https://bitbucket.com/andrewschultz/[name].git

To change a message:
git commit --amend -m "save and undo bugs fixed, #18 closable"
(only if others not using it)
git push --force

git fetch https://github.com/JasonLautzenheiser/trizbort

mkdir /path/to/your/project
cd /path/to/your/project
git init
git remote add origin https://andrewschultz@bitbucket.org/andrewschultz/new-project.git

Create your first file, commit, and push

echo "Andrew Schultz" >> contributors.txt
git add contributors.txt
git commit -m "Initial commit with contributors"
git push -u origin master

git diff is a big command to see WHAT is changed--it's so useful to get rid of debug text and so forth.

git checkout -b altfix
(make changes)
git commit -m "#225 about: added basic stuff"
git push --set-upstream origin altfix
git checkout master

git checkout (unmodified file) reverts it.
git reset --hard will undo everything, which is really harsh.

To get rid of a tracked file or no longer track it:
git rm -r --cached .
git add .
git commit -m "fixed untracked files"

To keep up to date with the master branch:
git pull http://github.com/jasonlautzenheiser/trizbort
git push


4 comments:

  1. I would recommend Git Extensions for everyone including developers. It's really a fantastic UI for Git.

    ReplyDelete
    Replies
    1. Thanks, I've heard of it--I'm comfortable with command lines, but then once the right GUI comes along, well, yeah. I know I'd love to see more quickly what my changes are, etc.

      https://gitextensions.github.io/

      Delete
  2. Some of my tips:

    git status is what I look at all the time. It shows the current branch and the list of new and modified files since last commit. I type it so much that I made a custom shortcut st that maps to git status -s (-s makes the output more compact.)

    [color]
    ui = true

    in .gitconfig file makes Git use colors to highlight stuff in output, especially useful with git status.

    ReplyDelete
    Replies
    1. Great point! I forgot to add that, for some reason, maybe because I use it too much in Git Shell.

      I didn't know about -s. But that's how it is. I'll use a command for months, not worrying about the fiddly options--then the options make so much sense.

      Git status had colors turned on by default, and the red/green/blue is super helpful.

      Delete