Create a project on your machine.
Run git init to initialize a git repository for your project.
Modify some files in your project.
Run git status to see the changes you have made in your project.
Run git add –all to tell git that you want it to track all those files you changed.
Run git status again to see that git added all those files.
Run git commit -m “my commit message” to tell git that you want to commit these changes to your local repository. Now, every change you made is saved locally by git.
Run git status to see there are no modifications left.
Run git log to see the commit you just made.
Now you decide you want to make the code you commited public, so you create a public repository on Github. Github tells you to do the following if you have an existing repository (you have an existing repository because you ran git init in your project). What Github tells you to do is:
Run git remote add origin https://github.com/youraccount/yourepository.git. This command adds a “remote” to your local repository. A remote is a special word that means “the link of the public repository you want to push to”.
Run git remote -v to see the new remote you added with the name “origin”
Run git push -u origin master. git push is the command to send the commits to the public repository. “origin” is the remote repository you are sending your changes to. “master” is the branch you want to send to that remote repository.
Now the cycle starts over again: modify some files, run git add –all, run git commit -m “my other commit message”, run git push. And puff, you are a pro using git.
Remember that you can run git status and git log at any time to see the current status of your local repository.