I'm using github to work on a project with two other people and am getting very confused about the whole commit thing, and nothing I'm reading is helping me understand. I get that commit records changes that you've made to a local repository... but then why are my group members' commits showing up on the online repository? Can you commit to both the local repository on your computer as well as an online repository? If you can commit to an online repository, what is the difference between doing that and simply using git push to push your changes online? Thank you kindly.
Let's say you are starting a new repository. You'd have to start local first, right? So,
git init
-> Initializes a repository on your local computer. (assuming you started with an empty folder)
Now you have an empty repository. Now it's time to add lots and lots of awesome code/content. Once you have some code, you will commit
.
git commit
-> Git will still keep all your changes locally; but remembers all the changes you made in this commit.
Let's say you make a couple of more changes, and want to save your work. So, you'll run the commit
again. Git again saves your changes, but in commit #2, still local to your computer.
Now you are ready to share your work with other people. Because Github repo's are online (typically), you will have to push
(i.e. upload) your changes to a remote repository.
Difference between commit
and push
is, the first one keeps all your changes locally on your computer (no one else in your team has access to your changes or commits), and push
will make your code available to everyone. Hope that's clear!