Attention: : Confluence is not suitable for the storage of highly confidential data. Please ensure that any data classified as Highly Protected is stored using a more secure platform.
If you have any questions, please refer to the University's data classification guide or contact ict.askcyber@sydney.edu.au

2. Sharing our repository

  • Git has 3 major platforms for code sharing:
  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

  • Adding our remote server with the REMOTE command. We refer to this server as "origin", you could use any name though

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

  • Showing our current remote repositories

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

  • Pushing our files/changes to our remote repository

$ 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

  • Removing our repository

$ cd ..
$ rm -rf git_tutorial


  • Cloning from the remote repository we've just pushed our files

$ 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