Authors: @Jacqueline Osborn, @Kendall Hester, @Kelley Chau, @Yousef Ahmed
Adding files lets you put the files and their changes (including things like deleting or adding a file) in a commit and eventually those changes get pushed to main.
# Check before adding and committing
$ git branch # make sure you’re on the right branch
$ git status # view which files were changed
$ git diff # view the changes
# Add and commit your code
$ git add <changed files you want to add>
Commits are little code checkpoints- when you push, you'll be able to look through your code at each commit and revert back to one if needed.
$ git commit <files you want to commit> -m “Commit message here”
In git commit -m
, the -m
flag allows for an in-line message that directly follows. This is really convenient and much faster!
If you don’t want to use the -m
flag, you can alternatively do: $ git commit <files you want to commit>
This will open a text editor (maybe vim).
i
to enter “Insert mode” — this will allow you to type text like you would expect.esc
key on your keyboard:w
to write (save), then :q
to quit. Alternatively,:wq
and :x
are both commands to write and quit at once.j
and k
to scroll up and down, and h
and l
for left and right.