Now that you know how to create a branch to make your changes, time to actually make the changes!
Doing so is pretty self-explanatory, once you're in your branch, edit files however you see fit. You can add and delete files, reorganize directories, and change code and Git will track it all.
Once you're ready to actually push these changes, they need to be staged and then bundled in a commit. Think of staging as telling Git "Hey, these are the files I'd like to group together." and then making a commit is actually doing the bundling.
Commits are how Git tracks different changes to the codebase. Normally, we'd like to make commits as small as possible so that we have a record of how the repository is changing. Better to have a lot of small commits rather than a few big commits. Also, if something goes wrong in the code we can always revert the repo to a prior commit.
git add <file_path>
git add .
Note: It is much more common to just stage every altered file rather than pick and choose. However, if you only want to bundle certain files in a commit then feel free to do so.
git commit -m <commit_message>
Where <commit_message>
is a message describing what your commit does. To use the Pong example from before, a good description would be something like "allows user to change the background color"
.
git status
This is a very helpful command in showing you which files are and aren't staged. It also provides helpful commands to undo staging and commits if you ever need to do so.
- Create a file in the
people
subdirectory with your first and last name titledfirstname_lastname.txt
. - Put a random sentence inside.
- Add a line containing your name to the comment in
printer.py
- Run
python run.py
to see your name added to the chain! Change your own file as much as you'd like. - Stage the files and bundle them in a commit.