Github

Making your own copy of the code to work on

It's likely that you'll want to edit some of our code and then, later, when you're happy with the changes, to initiate a request for the administrator of the code to merge your changes in. There are a few ways to do this in Github, but I'll cover the easiest way here.

The easiest way (least technical) is to make a fork of the distribution in your own user space.

    1. View the code in github online.

    2. For example, go to the page: https://github.com/VH-Lab/vhlab_mltbx_matlibraries

    3. Click the fork button. It will prompt you to create a copy of the distribution in your own space.

    4. If you already have a copy of the code on your local machine, delete it.

    5. For example, navigate in your file browser to USERSPACE/Documents/MATLAB/tools and delete the original directory.

    6. On a command line prompt, navigate to the USERSPACE/Documents/MATLAB/tools directory.

    7. For example, in DOS/Windows, you might run COMMAND from the toolbar, and type cd C:\Users\MYUSERNAME\Documents\MATLAB\tools

    8. On the command line, download (clone) your fork onto the local disk.

    9. For example: git clone https://github.com/YOURGITUSERNAME/YOURFORK

    10. Make all your changes to the code

    11. Commit your changes to your local code. Navigate to the directory of your fork on the command line and type git commit -a -m "NOTE" where NOTE is a note of your changes.

    12. Push your changes back to your remote fork. git push

    13. When you are ready to ask the administrator to merge your changes back in, view your fork on githib, and click Pull request. Fill out the request.

    14. Keep working (repeat steps 6-10 to infinity!)

Making a copy of a repository and switching to your branch

    1. View the code in github online.

    2. For example, go to the page: http://github.com/VH-Lab/NDR-matlab

    3. Click the branches button to view the branches that are there. See the name of the branch you want (for example, maybe sophie5).

    4. If you already have a copy of the code on your local machine, delete it.

    5. For example, navigate in your file browser to USERSPACE/Documents/MATLAB/tools and delete the original directory.

    6. Clone the repository using git clone https://github.com/YOURRESPOSITORY

    7. On the terminal command line, change directories so you are inside of the repository directory (e.g., cd YOURRESPOSITORY)

    8. Checkout the branch you want by typing git checkout branchname (e.g., git checkout sophie5)

Working on a repository that you own (and share with PI or just a few people)

  1. View the code in github online.

  2. For example, go to the page: https://github.com/VH-Lab/vhlab_mltbx_matlibraries

  3. "Clone" the respository to your local computer. For example, navigate in your Terminal program using cd USERSPACE/Documents/MATLAB/tools and run git clone https://github.com/VH-Lab/YOURREPO

  4. Work on your code.

  5. Prepare your files for pushing back to GitHub. To do this, we will make a "commit" of the files you are working with. Make sure your Terminal current directory is inside your git distribution (e.g., USERSPACE/Documents/MATLAB/tools/YOURREPO). If you've made new files, add them to your commit with git add filename. Then, commit your changes with git commit -am "message", where message is a note about the changes you made (just a few words, but it is a good idea to make them something meaningful). Note that all git commands except for clone needs to be issued while your Terminal current directory is inside your REPO. Use pwd to see what the "present working directory" is.

  6. Push your changes back with git push.

  7. When you want to get new changes, "pull" them by changing to that directory and typing in the Terminal git pull. (Again, make sure your Terminal shell present working directory is inside your repo.)