From this point onwards, you will be managing your assignments with git
and submitting them through GitHub. The aim of this assignment is to get you familiarized with a common version control workflow.
Make sure you've forked this repository under your own GitHub account, and then clone your own repository to your computer. You will push the changes you've made to this document as submission to GitHub.
If the version control concepts or git
commands are still confusing to you, consider re-reading and following the online notes, or check out an interactive tutorial like Learn Git Branching.
-
Create a branch in this assignment repository named
submission
, then list all the branches you have (Hint: look at the Branch chapter of notes on how branches work, how to create new ones, and check existing branches):# git command used and new list of branches
-
List the current
remote
name and hyperlink destination of this assignment repository (Hint: if you are not sure, add--help
after your command to check remotes.).# your git command and output here
-
Add a second remote destination named
upstream
to your assignment repository,upstream
is a common name used for the repository that people have forked from, in our case, theupstream
will be athttps://github.com/WCM-datascibasics/version_control_assignment
. List the new list of remotes after you've added the new remote.# list the new list of remotes here
-
Save your modifications to this file so far and create a commit indicating you've answered the first 2 questions. Then try pushing the changes to the
upstream
destination on GitHub. What happens? Explain in your own words why does this happen? What are the benefits of having thisupstream
remote added when working collaboratively (Hint: read git command outputs!)?Your answer here
-
Now clone the repository for the class website, and in the class website repository:
-
a. Explore the version history by visualizing it as a graph (remember the dog meme?).
# git command and output here
-
b. Who was the last person to modify
README.md
? (Hint: usegit log
with an argument)# git command and output here
-
c. What was the commit message associated with the last modification to the
-Week 2
line ofindex.md
file? (Hint: usegit blame
andgit show
, check out their help pages if you are not sure what to do)
-
-
In the course website repository (or another repository you want to clone from GitHub), modify one of its existing files, do not
git add
orgit commit
yet:- a. What happens when you do
git stash
, be specific about what happens to your uncommitted changes afterstash
.?Answer here
- b. What do you see when you run
git log --all --oneline
after stashing your modification?Answer here
- c. Look up what
git stash drop
andgit stash pop
does, either Google or use--help
. Rungit stash drop
to undo what you did withstash
, in what scenario mightstash
-ing,pop
-ing, anddrop
-ing be useful?Answer here
- a. What happens when you do
-
One common mistake when learning
git
is to commit large files that should not be managed bygit
or adding sensitive information like security keypairs for Amazon Cloud Services. Navigate back to your assignment repository and try adding a random text file to the repository (usetouch
), making some modifications and commits to your repository, and deleting that file withrm
. But deleting withrm
will not delete that file's recorded git history, therefore we need to do a little more. You may want to look at this)Perform the commits and deletion, this question will be graded based on your commit history on GitHub. I should see commits for when you added your file and made modifications, and I should see a commit for when you deleted the files.
-
Like many command line tools,
git
provides a configuration file (or dotfile) called~/.gitconfig
. Create an alias in~/.gitconfig
so that when you rungit graph
, you get the output ofgit log --all --graph --decorate --oneline
. You can do this by directly modifying the~/.gitconfig
file or by using thegit
command line functionality.# Your alias entry or git config command here
This is also a good opportunity to turn your dotfiles folder into a version controlled repo (Use
git init
in your dotfiles folder), make it private if you have sensitivessh
configurations there (IP Addresses), else feel free to make it public. (This is for your own benefit, not part of the assignment grading) -
You can define global ignore patterns in
~/.gitignore_global
after runninggit config --global core.excludesfile ~/.gitignore_global
. Do this, and set up your globalgitignore
file to ignore OS-specific or editor-specific temporary files, like.DS_Store
, or.vscode
. Feel free to Google around for common gitignore entries for Python projects or other projects of your interest.# Your .gitignore_global entries here
-
Push the
submission
branch of your repository to your GitHub remote. Your remotemain
/master
branch should be unchanged since your fork. Now go to your GitHub repository settings and addaxiezai
as a collaborator. Now create a pull request to merge the changes fromsubmission
tomain
/master
, assign your TAaxiezai
as a reviewer. You will receive feedback and grades through the pull request review.