A remote repository is just another copy of the git repository to which yours is linked. It can be on the same comuputer in a different file location, on a different computer, for example a departmental servr, on the laptop of a collaborator who is also working with you or on a git hosting service.
The main sites are
github
bitbucket
gitlab
You create a new repository by clicking the green "New Repository", give it a name, and optionally a description, licence, gitignore and README.
When we cloned the repository earlier that was a read only operation at the remote end. Now we are going to write to the remote repository we need to be authorised to do it. To avoid having to repeatedly put in the passowrd we'll ask git to cache the credentials
train31@myVM:~/git-lesson/workshop-test$ git config credential.helper cache
train31@myVM:~/git-lesson/workshop-test$ git remote
origin
train31@myVM:~/git-lesson/workshop-test$ git remote -v
origin https://github.com/christopheredsall/workshop-test.git (fetch)
origin https://github.com/christopheredsall/workshop-test.git (push)
git fetch
remote: Counting objects: 3, done.
remote: Compressing objects: 100% (2/2), done.
Unpacking objects: 100% (3/3), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
From https://github.com/christopheredsall/workshop-test
582e532..765c3bb master -> origin/master
git pull
does a git fetch
followed by a git merge
$ git status
On branch master
Your branch is behind 'origin/master' by 1 commit, and can be fast-forwarded.
(use "git pull" to update your local branch)
nothing to commit, working directory clean
$ git pull
Updating 582e532..765c3bb
Fast-forward
file2.md | 1 +
1 file changed, 1 insertion(+)
create mode 100644 file2.md
If we have made changes to our local repository we want to get them in to the remote. We use the git push
command to do that. The first time trhough it will give you a warning about how the default behavour has changed. You can do what it suggests to get rid of the warning next time
git config --global push.default simple
$ git push
Username for 'https://github.com': christopheredsall
Password for 'https://christopheredsall@github.com':
Counting objects: 3, done.
Delta compression using up to 16 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 320 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To https://github.com/christopheredsall/workshop-test.git
765c3bb..e031f0f master -> master
git clone https://github.com/christopheredsall/workshop-test.git
It is called origin by default
git remote
git remote -v
git pull
nano new.md
git add new.md
git commit -m "some new work from my laptop"
git config --global push.default simple
git push