What is version control? →
Version control software allows you to record changes to a file or set of files over time. With version control, you can:
Why use version control anyway? →
What version control software are we using? What is the website we use to store assignments? What is the relationship between the two? →
What is a repository, local repository, remote repository, commit, and diff? →
In your local repository, describe what is contained in the: working directory, index and HEAD. →
What is the primary way that we use git? That is, what is the root command, and what can we do with it? “Where” do you have to be to use git? →
What’s the workflow for setting up repositories for our assignments? (just the high level description, not the actual commands) →
What are the actual commands that you would use to set up and link your repositories? →
# create a local repository
git init
# configure it with your name and email
git config user.name "your name"
git config user.email "your@email.address"
# create a remote repository
curl -u 'your github user name' https://api.github.com/user/repos -d '{"name":"your repository name"}'
# link the two
git remote add origin url_to_your_repo_on_github
One of the previous commands was not a git command? Which one was it? Explain what it does. →
# creating a remote repository on github can be done with curl:
# curl makes a request to github with the username and data you provide
# -u means your username:
# replace 'your github user name' with your username
# -d means data:
# replace 'your repository name' with the name you'd like to
# call your new remote repository
# keep EVERYTHING ELSE as is
curl -u 'your github user name' https://api.github.com/user/repos -d '{"name":"your repository name"}'
Explain what each part of the following command means →
git remote add origin url_to_your_repo_on_github
Sometimes you need to troubleshoot your remote repository connection.
# show remote repositories
git remote -v
# or ...
cat .git/config
# remove / delete an associated remote repository
git remote remove name_of_remote
# change / set the url of a named remote
git remote set-url name_of_remote the_updated_url
What’s the workflow for making, saving and sharing changes? →
What’s are the actual commands that you use for making, saving and sharing changes? Let’s start with just making the change and prepping it to be saved. →
# (make changes)
# show the exact, line-by-line changes that you've made
git diff --color
# check on the status of your changes
git status
# stage your changes / prep them to be saved
git add --all
# (continued...)
Saving and sending to the remote repository →
# check your staged changes
git status
# save them, make sure you remember your comment by using -m!
git commit -m 'my message'
# show a history of your changes
git log --color (show your changes so far)
# send to your remote repository
git push origin master
What does git status do? →
git status - show what changes are ready to be committed as well as changes that you are working on in your working directory that haven’t been staged yet
git add marks a file or files as ready to be saved.
There are two ways to use it: →
# add all
git add --all
# add specific file
git add relative/path/to/myfile.txt
When you commit (save) remember to add a commit message using the -m option.
# in the directory of your repository
git commit -m 'commit message goes here'
If you’re having issues sending your changes to your remote repository (github)…
Show your remote repository names and urls:
git remote -v
The output should look something like…
origin https://github.com/bzuckerman/lab-06-javascript-conditionals.git (fetch)
origin https://github.com/bzuckerman/lab-06-javascript-conditionals.git (push)
If it’s incorrect, try changing the associated url:
git remote set-url origin https://github.com/your_github_user_name/lab-06-javascript-conditionals.git