-
Create a new directory on your Desktop called git_exercises and cd into that directory. cd Desktop mkdir git_exercises cd git_exercises/
-
Using
git init
, create a new repository. git init -
Using the
touch
command, create empty files called foo and bar in your repository directory. touch foo.js touch bar.js -
Enter
ls
to make sure they were added. ls -
Check your
git status
. git status -
Using
git add foo
, addfoo
to the staging area. Confirm withgit status
that it worked. git add foo.js git status -
Using
git commit -m
add an appropriate message, add foo to the repository. git commit -m "that foo" -
Check your
git status
. git status -
Using
git add bar
, add bar to staging area. Confirm with git status that it worked. git add bar git status -
Now run
git commit -m
option, and add the message“Add bar”
. git commit -m "Add bar" -
Using
git log
, confirm that the commits made in the previous exercises worked correctly. git log commit e99e805e0b56f69b56448e159b7eca8a629e4f5c (HEAD -> master) Author: syn perez [email protected] Date: Fri Sep 27 23:01:30 2019 -0400Add bar
commit ec04fced9b3340976822819351aefc96273c0576 Author: syn perez [email protected] Date: Fri Sep 27 22:59:15 2019 -0400
that foo
-
Use touch to create an empty file called baz. touch baz.js
-
Check that it's there by entering
ls
. ls -
Check the status of your git. git status
-
Add baz to the staging area using
git add .
, then commit with the message"Add bazz"
. git add baz.js git commit -m "Add bazz" -
Realizing there’s a typo in your commit message, change bazz to baz using
git commit --amend -m Add baz
. git commit baz.js --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. git log git show commit 565fc29f205cccb5dbe4d73bbc163f2a8365326c (HEAD -> master) Author: syn perez [email protected] Date: Fri Sep 27 23:05:59 2019 -0400add baz
diff --git a/baz.js b/baz.js new file mode 100644 index 0000000..e69de29
-
The
git log
command shows only the commit messages, which makes for a compact display but isn’t particularly detailed. Verify by runninggit log -p
that the-p
option shows the full diffs represented by each commit. Pressq
to escape. git log -p //q -
Create a file
README.md
, add and commit it. touch README.md git add README.md git commit -m "read me" -
Got to github and create a new repository. Connect your local repo to the remote one. git remote add origin https://github.com/synperez/Git-lab-set-third-set.git git push -u origin master
-
Open your README.md and and add the line
# hello there
at the top ofREADME.md
and save. //added # hello there to README.md -
Check the status, then add, check the status, and then commit the new line with a commit message of your choice. Verify using
git status
that the change was committed as expected. git status git add README.md git status git commit -m "obi wan" git status -
Push your changes:
git push origin master
. Refresh your github and click on the commit to verify the changes. git push origin master`
- 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/).
code . //added copied text git status git add README.md git status git commit -m "fourth set firmware update" git status git push //made a mistake, fixed it code . //updated copied text git status git add README.md git status git commit -m "fourth set firmware update ver 2" git status git push
-
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.