Topics: Source Control, BitBucket, Git basics
Group work: Group work is allowed for the labs, but each person must do their own coding and each person must turn in an assignment. Copying other peoples' code / code files is not allowed. Copied assignments will receive 0% for everybody involved.
Source Control is a necessary tool for developers and all programmers should have some level of fluency with it. During this semester, you will be storing your projects in a repository.
Use the documentation provided (class lecture, external reading, asking questions) to complete the following:
If you're on a school computer, Git is already installed. If not, go to https://git-scm.com/downloads and install the version for your operating system.
The Git installer will install Git Bash and Git GUI; you can use either of these for this lab but I'm giving the Bash (command-line) instructions.
Go to BitBucket.org and create an account.
I've created a student repository here: cs250-student-repo">cs250-student-repo.
This creates starter files for some of the labs and a simple README file.
Click on the "+" button on the left bar, then click Fork this repository to make a copy to your account.
Make sure to check This is a private repository, then click Fork repository.
There are several ways you can access git after installing it.
To view the current directory where Git Bash is open in, you can use the pwd
command:
$ pwd /home/rach/temp
To view what files/folders are in the current directory, use the ls
command:
$ ls discrete-structures edu-moosader-homepage cs134-programming-fundamentals other-teachers-resources cs200-concepts-of-progamming-algorithms page-content cs-211-001-82502-dot-201808-export.imscc server.sh cs250-data-structures cs250-student-repo
To move back one folder, you can use the cd ..
command. To enter a folder, use the cd FOLDERNAME
command.
Click on the Clone button and copy the git clone command it gives you.
(Windows) Open Git Bash, the command prompt, or PowerShell on your machine's desktop. (Open command prompt: SHIFT+RIGHT-CLICK)
(Linux/Mac) Open the Terminal and navigate to where you want to store your projects.
Paste the git clone command and hit ENTER.
Sign in using the popup that shows up. If that doesn't work, run the command again and "cancel" out of the popup and sign in from the terminal.
Now the cs250-student-repo will be on your computer.
In the terminal, make sure you're in the cs250-student-repo directory (Use cd PATHNAME] to enter the folder).
Keep the terminal open for now.
$ git clone https://rejcx@bitbucket.org/rachelsteaching/cs250-student-repo.git Cloning into 'cs250-student-repo'... remote: Counting objects: 183, done. remote: Compressing objects: 100% (171/171), done. remote: Total 183 (delta 57), reused 0 (delta 0) Receiving objects: 100% (183/183), 2.34 MiB | 2.20 MiB/s, done. Resolving deltas: 100% (57/57), done. Checking connectivity... done.
Navigate to the directory where your repository is and open up README.txt in a text editor. Change some text in the file and save it.
Type git status
in the terminal and hit enter. It will tell you what files have changed and are awaiting commit.
$ git status On branch master Your branch is up-to-date with 'origin/master'. Changes not staged for commit: (use "git add..." to update what will be committed) (use "git checkout -- ..." to discard changes in working directory) modified: README.txt no changes added to commit (use "git add" and/or "git commit -a")
Type git add README.txt in the terminal and hit enter.
Type git commit -m "asdf" in the terminal, replacing asdf with a description of what you have changed.
Now your changeset is saved locally, but not on the server.
Type git push in the terminal to push your changes to the server.
Go to the web-view of your repository to ensure that your changes show up now.
Take a screenshot of your repository front page and upload it as the assignment file.
You should upload your future labs, projects, and notes to this repository.
We will make the repository public at the end of the semester.