-
Notifications
You must be signed in to change notification settings - Fork 0
/
git_remote.txt
83 lines (64 loc) · 2.26 KB
/
git_remote.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
Content-Type: text/x-zim-wiki
Wiki-Format: zim 0.4
Creation-Date: 2012-07-18T17:37:45.738425
====== Git Remote ======
git remote 基本用法
Created 星期三 18 七月 2012
git是一个分布式代码管理工具,所以可以支持多个仓库,在git里,服务器上的仓库在本地称之为remote。
直接clone一个仓库:
$: git clone [email protected]:projects/search.git
另外一种clone方式:
# 创建目录初始化本地仓库
$: mkdir search && cd search
$: git init
# 添加远程仓库路径
$: git remote add github [email protected]:yyfrankyy/search.git
# 实际上,pull 就是 fetch + merge
$: git pull github --all --tags
把工作目录迁移到github上面:
$: git remote add github [email protected]:yyfrankyy/search.git
$: git push github --all --tags
显示所有的远程仓库
$: git remote -v
origin [email protected]:projects/search.git (fetch)
origin [email protected]:projects/search.git (push)
github [email protected]:yyfrankyy/search.git (fetch)
github [email protected]:yyfrankyy/search.git (push)
重命名远程仓库
$: git remote rename github gh
$: git remote
origin
gh
删除远程仓库
$: git remote rm github
$: git remote
origin
从远程仓库抓取数据,更新本地仓库:
$: git fetch origin
remote: Counting objects: 58, done.
remote: Compressing objects: 100% (41/41), done.
remote: Total 44 (delta 24), reused 1 (delta 0)
Unpacking objects: 100% (44/44), done.
From git://search.ued.taobao.net:projects/search.git
* [new branch] product -> origin/product
查看远程仓库信息,可用于跟踪别人的push:
$: git remote show origin
* remote origin
Fetch URL: [email protected]:projects/search.git
Push URL: [email protected]:projects/search.git
HEAD branch: master
Remote branches:
master tracked
p4popt tracked
prepub tracked
product tracked
Local branches configured for 'git pull':
master merges with remote master
p4popt merges with remote p4popt
prepub merges with remote prepub
product merges with remote product
Local refs configured for 'git push':
master pushes to master (up to date)
p4popt pushes to p4popt (up to date)
prepub pushes to prepub (up to date)
product pushes to product (up to date)