Git remote repository
Let’s make a practise.
Init local repository
Initialize a local repository.
1 |
|
First commit
Create file
1 |
|
On branch master
Initial commit
Untracked files:
(use “git add …” to include in what will be committed)
README.md
nothing added to commit but untracked files present (use “git add” to track)
Staging file
1 |
|
On branch master
Initial commit
Changes to be committed:
(use “git rm –cached …” to unstage)
new file: README.md
Commit file
1 |
|
[master (root-commit) 3e9292a] first commit
1 file changed, 1 insertion(+)
create mode 100644 README.md
git status
On branch master
nothing to commit, working directory clean
First push
Create Github repository
We usually use Github
as our code host.
Push your code
Synchronize you local repository to remote host.
1 |
|
Counting objects: 3, done.
Writing objects: 100% (3/3), 252 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To https://github.com/Rugal/learn-git.git
* [new branch] master -> master
Track remote repository
This is set to track the remote status, so that Git could compare the difference between local and remote repo.
1 |
|
Branch master set up to track remote branch master from origin.
On branch master
Your branch is up-to-date with ‘origin/master’.
nothing to commit, working directory clean
The tricky point is that, origin/master
is not special. It is a local cache of the remote branch. But you can’t change this origin/master
branch unless by git fetch/push
.
So basically each time you do git fetch/push
, the origin/master
branch will be synced with real remote master
. Then you will know the differences between your local development branch and real remote branch by comparing the local master
with the local origin/master
.
Git remote repository
https://rug.al/2016/2016-10-02-git-remote-repository/