Lab 4 - Part 2 - Saving and Sending Changes to Your Repository
In this lab, you’ll be:
- creating and editing files in your local repository
- saving those changes
- sending those changes to your remote repository on github
Instructions
Creating and Saving Changes Locally, Sending to Remote Repository
In this part of the lab, you will create a text file in your local repository, and then you’ll send it to your remote repository.
- open terminal
- make sure you’re in your local repository folder for lab-04-version-control
- use pwd to do this
- you should be in ~/Desktop/yourname/lab-04-version-control
- if you’re not in your lab folder, change your directory to it
- if this doesn’t exist yet… make sure you completed the first part of this lab
- use git status to show that there aren’t any changes yet
git status
- it should give the following output
# On branch master
#
# Initial commit
#
nothing to commit (create/copy files and use "git add" to track)
- create a file called README.markdown
- use touch to do this
- use nano to edit README.markdown
nano README.markdown
- type in the following line
This is lab 04
- exit and save your file (<ctrl-x>,<y>,<enter>)
- use git status to show that you’ve made changes
git status
- it should give the following output; notice that it contains README.markdown
pines:lab-04-version-control bree$ git status
# On branch master
#
# Initial commit
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# README.markdown
nothing added to commit but untracked files present (use "git add" to track)
- if we want to save this file in the repository, we have stage it (that is, mark it as something that we’re ready to save / commit)
git add --all
- to check that you’ve staged your commit, use git status again
git status
- it should output the following text (note that README.markdown moved from untracked to Changes to be committed)
# On branch master
#
# Initial commit
#
# Changes to be committed:
# (use "git rm --cached <file>..." to unstage)
#
# new file: README.markdown
#
- now we’re ready to commit (that is, save the file to the local repository); everything after the -m is the message that will be associated with the changes that you’ve made
git commit -m "added a README file"
- the output of the command should be:
[master (root-commit) 7a2e2f6] added a README file
1 file changed, 1 insertion(+)
create mode 100644 README.markdown
- check the status again
git status
- notice that there is nothing staged and no more changes!
# On branch master
nothing to commit, working directory clean
- to show the changes that you’ve saved so far, use git log
git log --color
- it should show you the following…
commit 7a2e2f6ff86407b7707f78cf8c9a12b1dd843de9
Author: bree <bzuckerman@citytech.cuny.edu>
Date: Wed Feb 26 08:54:14 2014 -0500
added a README file
- you can share your changes / send them to a remote repository by using git push
git push origin master
- it should result in:
Counting objects: 3, done.
Writing objects: 100% (3/3), 242 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To https://github.com/bzuckerman/lab-04-version-control.git
* [new branch] master -> master
- go back to github and look in your repository. you should see that file appear.
Making Changes, Showing Changes, Showing History
In this part of the lab, you will make changes to an existing file.
- add another line to your README.markdown
This is lab 04
It's about version control
- use git diff to show your changes
git diff --color
- use git status, add and commit to save your changes
- finally, use git push to send them to your remote repository
- check that they are in your folder
(Optional) Practice Making Changes / Adding Files
- create another file called test.sh
echo "hello"
- save locally and push to your remote repository