Wiki

Clone wiki

picoware-game / Git Help

Git Help

We will be using Git to maintain our code and manage getting updates to everyone working on the project.

Git can be pretty daunting because it has so many options, and is often associated with cryptic command line tools. When you stick to the basics though, it's not too hard at all. Follow the steps below, and you'll have the workflow down in no time!

Step 1: Clone This Repo

This step will have you use Git to download a copy of all the game code.

With Git, you can pull updates from the rest of the team, and push out any of your own work to everyone else. It does a decent job of merging changes that multiple people make in a single project, making it easier for teams to work on a single codebase. It also keeps a full history of changes so if anything goes wrong you can revert back to old versions.

If you've never used Git, here is a guide using a free tool called SourceTree:

Using SourceTree

SourceTree is a Git client built for Windows. It is made by Atlassian, the same company that runs BitBucket. That makes it very convenient to work with this repo since, well, it's ON Bitbucket.

You can download SourceTree at https://www.sourcetreeapp.com/, and sign in with your BitBucket login.

When installing:

  • The only tool you need is Git (uncheck Mercurial).
  • In 'advanced options' you should probably check both 'Configure automatic line ending handling by default' and 'Configure Global Ignore'
  • You can just say no to the SSH key question

Once installed:

Open SourceTree, and you should see 2 buttons on the top left; Local and Remote. Make sure you are on the Remote view, and you should see the PicoWare repository over on the right. There should be a 'clone' link in that space. Click it.

You shouldn't have to change anything, unless you want to update the 2nd input and change where the game files will be downloaded. Hit the Clone button.

You will now have a copy of all the game files!

Step 2: Work on the Game

Refer to the framework documentation to figure out how to add levels and mini games. Work, test, work, test, etc etc..

Step 3: Commit your work

It's a good idea to commit your work every time you make any major changes, even if you aren't ready to push it to the rest of the team. It will keep track of any changes you've made on your local machine and give you revision numbers you can revert to if you ever mess anything up.

Using SourceTree

Stage your updated files

You should be seeing your local PicoWare repository in SourceTree. You should also see 2 boxes; Staged files and Unstaged Files. Anything in the Staged files box will be included in your commit.

You can add any unstaged file to the list by clicking the + icon beside it, or you can use the Stage All button to include them all.

If you accidentally stage a file that's not ready to be commited, you can click the - icon beside it.

Commit your work

At the bottom of the screen is a big text box with a 'Commit' button below it.

You can add notes here about what changes you've made so the rest of the team knows what's in this commit without having to look at all your individual changes. This can be a simple message like "added the Alien Hominid Whack-a-Mole game" or "Fixed a collision bug".

Below the text box is a checkbox that says "Push Changes immediately to origin/main". This should probably be unchecked to avoid merge conflicts on the remote repository.

When you've finished your notes, go ahead and click the Commit button.

Note: This records the state of your work on your local machine, but will not push it to the rest of the team.

Step 4: Pull Updates From the Remote Repository

This step is VERY important, and should ALWAYS be done before you push any work out to the team!!!

This will help you catch any conflicts between your work, and what the rest of the team has pushed before you push your own work and potentially erase anyone else's work.

Using SourceTree

At the top of the screen, click the Pull button. You shouldn't need to change any of the options in the next screen, but make sure "Commit merged changes immediately" is checked.

You'll see a progress bar. If it completes without any issues, you are good to go!

Step 5: Fix Merge Conflicts (if applicable)

Hopefully this won't happen very often, if at all, but sometimes when 2 people work on the same file, Git can't figure out how to merge your changes together.

Tip: One of the biggest culprits here is text editors that auto-convert tabs to spaces, so if your editor does that, you may want to consider disabling it.

When you pull from the remote repo, and there is a conflict, you should be presented with a warning message that will ask you to resolve the conflict before pushing.

Open the file(s) that have conflicts, and you will see areas like this:

<<<<<<< HEAD
This is code that only existed in YOUR copy
=======
This is code that only existed on the remote repo
>>>>>>> 3ead5ae20038e66d9046fc7ad48a064130f71dfa

You will need to manually merge these chunks of code together and test everything locally to make sure nothing is broken. DO NOT PUSH THESE FIXES WITHOUT TESTING THEM FIRST!!!!!

After you've fixed and tested the file(s), commit your changes again, and repeat Step 4 (people may have pushed new changes while you were fixing things).

Using SourceTree

When you have files with unresolved conflicts, SourceTree will show them (on the File Status view) with a triangle/exclaimation icon. The file may appear in both the Staged and Unstaged file lists.

Once you have fixed the conflict and saved/tested the file, you can click the + icon beside the version in the Unstaged list. This will change the icon in the Staged list telling you it is ready.

Step 6: Push Changes & Updates

Pushing with Git will send your changes to the remote repository where the rest of the team can pull them from.

Make sure you have followed all the steps above and have tested that the game still works before you do this!

Using SourceTree

Hit the Push button at the top of the app, and then hit the Push button on the next screen. That's all you should need to do!

If you have unresolved conflicts (see Step 5), the progress bar will be red and the push will have failed.

Once you've done all this, just keep repeating steps 2-6.

Updated