WDI Fundamentals Unit 2
This exercise will give you some practice using Git.
Open your terminal and go into to the
fundamentals directory you created earlier. Create a new directory inside it called
cd to navigate into that new directory; you can make sure you're in the right place by using the
git init to create a Git repository in the
git init, make sure you're not already inside another Git repository. Type
git status. If you see
fatal: Not a git repository (or any of the parent directories): .git, then you know you're good to go, and you can safely run
git initwithin this folder.
Notice that there is now a
.git directory in
git-practice — you'll see it if you run the
ls -a command.
Create a new file called
README.txt and run
git status. What output do you get?
git add README.txt command to add the new file to the staging area. Run
git status again — how has the output changed?
Now that you're satisfied with the changes that you've staged, commit them using
git commit -m "...". Give the commit an appropriate message — remember, it should be short but descriptive.
Create a directory called
src and add a couple of files to it.
add command, but add the
src directory instead of the individual files. Use the
command — see how both files have been staged? Go ahead and commit the addition of these new files to the repo.
Make a change to one of the files, and run
git diff to look at all the unstaged changes to our repo. What do you see?
add the changed file and type
git diff. What's changed? Why? What do you have to do to see a
diff of the things in the staging area?
Now — without adding or committing — make another change to the same file you changed in step 9. Look at the
status output, and the
diff output. See how you can have both staged and unstaged changes, even when you're talking about a single file?
commit all outstanding changes. Use the
log command to see all of the commits you've made so far.