Courses‎ > ‎Software Development‎ > ‎

Resources

More resources coming soon...

Git Stuff:

Python Stuff:

Github Submodule Setup
  • If you need a refresher on using git in general, see "The Basics" section below.
Think of a submodule as a github repo inside another github repo (I know, woah).  Here's how things will generally be set up:
  1. Each class will have a repo for assignments.
  2. Each student/group will create a totally separate repo for their work
    • This should not live in the main work repo
  3. Each student/group will clone the main work repo, and then link their own repo as a submodule
  4. Each student/group will get rid of their local copy of the main repo
  5. Each student/group will work on their assignment in the repo created in step 2
Ok, but what about more instructions with examples you say?

2. Create & clone your own repo
Do all your work in this repo.
$ git clone https://github.com/jonalf/work-test.git
Cloning into 'work-test'...
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), done.
Checking connectivity... done.

3. Clone the main repo
$ git clone https://github.com/stuy-softdev/workshop.git
Cloning into 'workshop'...
remote: Counting objects: 14, done.
remote: Compressing objects: 100% (9/9), done.
remote: Total 14 (delta 5), reused 9 (delta 3), pack-reused 0
Unpacking objects: 100% (14/14), done.
Checking connectivity... done.

Change into the correct directory and add your repo as a submodule
$ cd workshop/
socrates: workshop dw$ cd randomizer/6/
socrates: workshop/randomizer/6 dw$ git submodule add https://github.com/jonalf/work-test.git jonalf_dw
Cloning into 'randomizer/6/jonalf_dw'...
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), done.
Checking connectivity... done.

Commit and push changes
$ git pull
Already up-to-date.
socrates:~/Desktop/git_demo/workshop/randomizer/6 dw$ git commit -a -m "added dw submodule"
[master f25eeda] added dw submodule
 2 files changed, 4 insertions(+)
 create mode 100644 .gitmodules
 create mode 160000 randomizer/6/jonalf_dw
socrates:~/Desktop/git_demo/workshop/randomizer/6 dw$ git push
Counting objects: 5, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (5/5), 626 bytes | 0 bytes/s, done.
Total 5 (delta 0), reused 0 (delta 0)
To https://github.com/stuy-softdev/workshop.git
   11dc0c6..f25eeda  master -> master
You do not have to pull first, but it is a good idea in case anyone has pushed before you have a chance to.

Remove the main repo and go about your business
$ cd ../../../
$ rm -rf workshop/


Using Git/Github: The basics

Cloning an existing project:
  For every assignment, you will need to clone the project repository You should only do this once per repository per computer. After you clone, the project directory will be downloaded onto your computer and all future git changes must be made inside that directory.

    use the following command to checkout:
$ git clone https://github.com/mks65-dw/<assignment name>.git
Cloning into 'hw1'...
remote: Counting objects: 4, done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 4 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (4/4), done.

    for example, to checkout an assignment called hw1 I would do the following:
$ git clone https://github.com/mks65-dw/hw1.git
Cloning into 'hw1'...
remote: Counting objects: 4, done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 4 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (4/4), done.

This will create a folder on your computer called (in this case) hw1. You must go into that folder to add your own directory.

Creating your own directory within a project:
    Once you have cloned the assignment, create a directory for yourself. Change into the assignment folder and make a new directory with the name: Firstname_Lastname. So mine would be JonAlf_Dyrland-Weaver. After you create the directory add it to the main repository and commit (see the instructions for adding and committing below)
    So to make my own repository to the project called hw1 from above:
$ cd hw1
$ mkdir JonAlf_Dyrland-Weaver
$ cd JonAlf_Dyrland-Weaver
    Once you make, add and commit the directory do all your work within the directory

Adding files:
    When you create a new file, it is not automatically tracked by git. You must tell git which files it should track. (This is useful because you don't want to add .o, ~ and executable files that may get created while working on your project, you may also look at .gitignore for more ways to keep out unwanted files). You only need to do this once per file. After it has been added git will track it. You cannot add an empty folder. Make sure you put something in a folder in order to add the whole thing
$ git add file.txt 
    You will not see any response after adding a file
Removing files:
$ git rm file.txt
rm 'JonAlf_Dyrland-Weaver/file.txt'
    Running git rm will also remove the file from your directory immediately

Committing your changes:
    When you add files, the changes are not automatically saved but git, you must commit these changes. You must always use the -m option followed by a string containing a commit message. You should commit anytime you have changes that are worth saving!
$ git commit -a -m "adding an initial file"
[master 5524096] adding an initial file
 0 files changed
 create mode 100644 JonAlf_Dyrland-Weaver/file.txt
    The -a option will automatically commit any changes to files that you have already added. You should always include -a (unless you know what you're in for)

Pushing your changes to gihub
    Committing is a local operation, it will not change the status of your work on gihub. You do this with the push command. When pushing, git may ask you for your username and password, (use your github account information) depending on how you have git set up.
$ git push
Username for 'https://github.com': jonalf
Password for 'https://jonalf@github.com': 
To https://github.com/mks65-dw/hw1.git
   8bd554d..5524096  master -> master

Updating your project to the latest version:
    When you start working in a new location (i.e. you worked in school, pushed your changes and now want to work at home with the latest version), pull any changes from github. This will make all of your files match with those on github.
$ git pull

Comments