码迷,mamicode.com
首页 > 其他好文 > 详细

git在本地创建工作空间并从远程版本库获取代码

时间:2015-02-05 13:04:19      阅读:129      评论:0      收藏:0      [点我收藏+]

标签:

1、
创建一个新的文件夹:
[root@centos http]# mkdir activityTestLee

2、
进入该文件夹
[root@centos http]# cd activityTestLee

3、
创建本地版本库:
[root@centos activityTestLee]# git init
Initialized empty Git repository in /http/activityTestLee/.git/

4、
获取钩子:
[root@centos activityTestLee]# scp -p -P 8849 lining@114.215.120.180:hooks/commit-msg .git/hooks/
Enter passphrase for key ‘/root/.ssh/id_rsa‘:
commit-msg 100% 4365 4.3KB/s 00:00

5、
从远程版本库进行克隆(相当于建立了一个链表,并没有把代码从上面copy到本地):
[root@centos activityTestLee]# git clone ssh://lining@114.215.120.180:8849/activity
Initialized empty Git repository in /http/activityTestLee/activity/.git/
Enter passphrase for key ‘/root/.ssh/id_rsa‘:
remote: Counting objects: 3082, done
remote: Finding sources: 100% (3082/3082)
remote: Total 3082 (delta 1140), reused 3031 (delta 1140)
Receiving objects: 100% (3082/3082), 13.35 MiB | 670 KiB/s, done.
Resolving deltas: 100% (1140/1140), done.

6、
查看当前从远程版本库获取的东西
[root@centos activityTestLee]# ls
activity

7、
进入到文件下面:
[root@centos activityTestLee]# cd activity

8、
查看当前服务器和本地的所有分支:
[root@centos activity]# git branch -al
* master
remotes/origin/HEAD -> origin/master
remotes/origin/develop
remotes/origin/huodong
remotes/origin/master
remotes/origin/production

9、
创建本地分支develop并从远程版本库分支上面获取内容(现在本地有代码了)
[root@centos activity]# git checkout -b develop origin/develop
Branch develop set up to track remote branch develop from origin.
Switched to a new branch ‘develop‘

10、
查看有哪些文件:
[root@centos activity]# ls
db deploy description.txt docs env_conf tools web

其实,可以从第五步开始,然后4-6-7-8-9-10

git在本地创建工作空间并从远程版本库获取代码

标签:

原文地址:http://www.cnblogs.com/leedanings/p/4274239.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!