- Create a new directory on your Desktop called git_exercises and cd into that directory.
- Using
git init, create a new repository. - Using the
touchcommand, create empty files called foo and bar in your repository directory. - Enter
lsto make sure they were added. - Check your
git status. - Using
git add foo, addfooto the staging area. Confirm withgit statusthat it worked. - Using
git commit -madd an appropriate message, add foo to the repository. - Check your
git status. - Using
git add bar, add bar to staging area. Confirm with git status that it worked. - Now run
git commit -moption, and add the message“Add bar”. - Using
git log, confirm that the commits made in the previous exercises worked correctly.
- Use touch to create an empty file called baz.
- Check that it's there by entering
ls. - Check the status of your git.
- Add baz to the staging area using
git add ., then commit with the message"Add bazz". - Realizing there’s a typo in your commit message, change bazz to baz using
git commit --amend -m Add baz. - Run git log to get the id of the last commit, then view the diff using
git show <id>to verify that the message was amended properly.
- The
git logcommand shows only the commit messages, which makes for a compact display but isn’t particularly detailed. Verify by runninggit log -pthat the-poption shows the full diffs represented by each commit. Pressqto escape. - Create a file
README.md, add and commit it. - Got to github and create a new repository. Connect your local repo to the remote one.
- Open your README.md and and add the line
# hello thereat the top ofREADME.mdand save. - Check the status, then add, check the status, and then commit the new line with a commit message of your choice. Verify using
git statusthat the change was committed as expected. - Push your changes:
git push origin master. Refresh your github and click on the commit to verify the changes.
- Using the markdown below, add a line at the end of the README with a link to the official Git documentation:
~/repos/website/README.md
For more information on Git, see the
[official Git documentation](https://git-scm.com/).-
Commit your change with an appropriate message. Why not?
-
Push your change to GitHub. By refreshing your browser, confirm that the new line has been added to the rendered README. Click on the “official Git documentation” link to verify that it works.