4
* Git tracks so called 'remotes'. 'origin' is a standard remote normally telling where is the package cloned from.
5
Remotes are just named references to remote git repositories. Information about configure remotes:
7
* Now, some association between local and remote branches can be configured. A specific local branch can be configured
8
to monitor changes in the specific branch of one for the remotes. On clone, the local 'master' branch will start tracking
9
the changes on the 'master' branch of remote 'origin.
10
git config --get branch.master.remote - Get remote associated with local branch 'master'
11
git config --get branch.master.merge - ?
12
* All remotes have own set of branches. When you clone package infromation about all its branches is downloaded. Plus a new
14
git remote set-url <remote> <new-url>
15
local branch 'master' is created. There are many operations which can be performed on the remote branches. It is possible to
16
checkout the remote branchike with local: checkout them, merge from them, etc. Information about available remote branches
20
git remote add <remote-name> https://github.com/<package>.git
21
git fetch <remote-name> [refspec] - retrieves refs and objects from the remote branch
22
git pull <remote-name> [refspec] - fetch + merge into the current branch
24
git push <remote-name> [refspec] - and other way arround
25
git push origin master - will push back the modified master branch
26
* The tags are not pushed automatically
27
git push <remote-name> --tags - pushes all tags
28
git push <remote-name> <tag_name> - pushes specific tag
29
* If multiple users are sharing remote repository, the merge should be performed before. Standard procedure is following
30
'git fetch' last changes from the server into the refs/remotes/heads/<branch>
31
Merge the revision into the refs/heads/<branch>
33
* Remove remote branch
34
git push <remote-name> :refs/heads/invalid - or '--delete <remote-ref>'
35
* Get more information about remote
36
git remote show <remote-name>
39
- RefSpec is used to associate local and remote branches.
41
* In the simplest form it just associates two refs
42
+refs/heads/master:refs/remotes/origin/master
43
i.e. if 'get fetch' is executed, the remote master branch will be synchronized locally to the refs/remotes/origin/master
44
* Many things can be ommited and auto-detected by git. The refspec can be as simple as
46
which would first resovled to 'refs/heads/master' and then the same repository will be considered on the other side.
47
* It is also possible to associate multiple branches
48
+refs/heads/test_*:refs/remotes/origin/test_*
49
* The '+' allows git to perform update even if the branches diverged and fast-forward is not possible.
50
- For synchronization in 'refs/remotes' it is completely fine (and actually could happen if some weird changes happened upstream)
52
So, lets consider default configuration when remote is created: .git/config get updated and refspec is given for 'fetch' action. Like
53
that. This actually means that we will synchronize all the remote branches:
54
fetch = +refs/heads/*:refs/remotes/origin/*
55
* Now we can limit ourselves to a single branch
56
fetch = +refs/heads/master:refs/remotes/origin/master
57
* Synchronize directly to the local master if branches have not diverged (no plus sign)
58
fetch = refs/heads/master:refs/heads/master
59
* Multiple fetch refspecs can be configured in the configuration by including 'fetch =' statement multiple times
60
* The same it is possible to configure automatic 'push'. Though '+' should not be used in this case :)