1. GitHub (http://www.github.com)
  2. Bitbucket (http://www.bitbucket.com)
  3. Gitlab (http://www.gitlab.com)

We are going to use Github since its a free and easy to use platform, but any Git based platform would work in the exact same way

Step 1: Create a github/bitbucket/gitlab account

Step 2: Create a repository See Here an Example

Step 3: Get your repository URL

How to Share? The GIT REMOTE, PUSH, PULL and CLONE commands

GIT REMOTE and PUSH

$ git remote add origin https://github.com/rafaelpossas/git_tutorial.git

$ git remote -v   # Show remote repositories
origin https://github.com/rafaelpossas/git_tutorial.git (fetch)
origin https://github.com/rafaelpossas/git_tutorial.git (push)

$ git status
On branch master nothing to commit, working tree clean

$ git push -u origin master
Counting objects: 4, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (4/4), 386 bytes | 0 bytes/s, done.
Total 4 (delta 0), reused 0 (delta 0)
To https://github.com/rafaelpossas/git_tutorial.git
* [new branch] master -> master
Branch master set up to track remote branch master from origin.


We have pushed all our files along with our git history tracking to a remote repository, note that we pushed our changes to the 'master' branch, branches will be explained later

Usually on GIT the main branch is called master and the remote server is called origin

$ cd ..
$ rm -rf git_tutorial


$ git clone https://github.com/rafaelpossas/git_tutorial.git
Cloning into 'git_tutorial'...
remote: Counting objects: 4, done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 4 (delta 0), reused 4 (delta 0), pack-reused 0
Receiving objects: 100% (4/4), done.

$ cd git_tutorial
$ ls

GIT_TUTORIAL.txt README.txt

All our files were restored to the state of our last commit

GIT General Workflow overview