Where do you host your repositories? There are many different options for this. This example uses GitHub
First, you must register with GitHub
https://github.com/
After you've done it, make sure you remember your login details.
Create a repository by clicking

Give it a name

Do your work on the project
git add .
git commit -m "Behold my awesome feature"
Grab a link to your remote repository

Set up your remote repository on your machine
git remote add project01 https://github.com/edoroskevic/helloworld.git
Note: project01
can be replaced with whatever you like. It's simply a name for your remote repository that will be stored on your local machine.
After it has been set-up you can finally push your work to remote repository
git push project01 master
Note: project01
is the name I have given to this test repository and master
is the branch I will be pushing to my remote repository.
After executing the above command you will be asked to provide your login details to GitHub
(username, password). Enter those and check out your pushed updates on GitHub
.
You may get a nasty fatal error
when pushing. Saying something like...
Can't merge unrelated histories...
In that case you can run your push with -f
like so
git push -f origin master
Note: -f
will force the push on top of your remote. You can also add links between local and remote branches but this post is getting a bit too long.
Next time you are on another machine, you can
git clone https://github.com/edoroskevic/helloworld.git
This will clone the remote repository and set up all the links between branches automatically. Next you just keep doing your usual stuff adding, committing and pushing
Hope its helpful :s