Some notes about remote repo in Git
Basic Concepts
不是当前 repo 的 都是 remote repo,既可以在网络上,又可以在同一台电脑上。
remote branches 跟 local branches 相似,不过他们是另外一个 repo 的 branch。
The
git remote add
相当于添加了 另一个 repo 的书签,方便以后使用。fetch 和 push 几乎相反,因为 fetching imports branches,而 pushing exports branches to another repo.
git push
不能自动地 push 一个特定分支上的 tags,所以如果有必要,需要手动 push tags。git remote
中列出的是remote-names
,他们起的是书签的作用,对应的是其他 repos的完整路径。remotes
是针对人的,而branches
是针对 topics 的. 不要为不同的开发人员创建不同的分支——这是项目开发的事情,而应该给他们单独的仓库,并用git remote add
区别开来。
Quick Reference
git clone <remote-path>
Create a copy of a remote Git repository.
git remote
List remote repositories.
git remote add <remote-name> <remote-path>
Add a remote repository.
git fetch <remote-name>
Download remote branch information, but do not merge anything.
git merge <remote-name>/<branch-name>
Merge a remote branch into the checked-out branch.
git branch -r
List remote branches.
git push <remote-name> <branch-name>
Push a local branch to another repository.
git push <remote-name> <tag-name>
Push a tag to another repository.
References
Ry’s Git Tutorial By Ryan Hodson
本作品采用《CC 协议》,转载必须注明作者和本文链接