歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> Git搭建團隊開發環境操作演練

Git搭建團隊開發環境操作演練

日期:2017/2/28 13:56:23   编辑:Linux教程

模擬創建遠程git倉庫

1.首先創建如下目錄結構:

/Users/hujh/Desktop/GitTest2/GitServer/weibo

weibo是我們要創建的項目

2.切換目錄

$ cd /Users/hujh/Desktop/GitTest2/GitServer/weibo

3. 建立空白代碼庫(專門用於團隊開發)

$ git init —bare

正常一般能顯示類似如下結果代表初始化空倉庫成功

Initialized empty Git repository in /Users/hujh/Desktop/Git演練/GitServer/weibo/

項目經理初始化本地倉庫

1.項目經理創建如下目錄結構:

/Users/hujh/Desktop/GitTest2/Manager

2.切換目錄

$ cd /Users/hujh/Desktop/GitTest2/Manager/weibo

3.”克隆"代碼庫到本地

$ git clone /Users/hujh/Desktop/GitTest2/GitServer/weibo/

顯示提示結果如下:

Cloning into 'weibo'...

warning: You appear to have cloned an empty repository.

done.

代表克隆倉庫成功,您可以進入weibo目錄通過

ls -la查看到如下圖結果:

有一個.git目錄,這就是倉庫的隱藏目錄。

4.個人信息配置(因為要演示一台機器上的多人協作,日常開發可以忽略)

$ git config user.name manager

$ git config user.email [email protected]

5.添加.gitignore文件指定哪些文件不納入版本庫的管理

參考網址:https://github.com/github/gitignore

1)在.git目錄的同級目錄中將如下命令粘貼執行

echo -e "# Xcode

#

build/

*.pbxuser

*.mode1v3

*.mode2v3

*.perspectivev3

xcuserdata

*.xccheckout

*.moved-aside

DerivedData

*.hmap

*.ipa

*.xcuserstate

# CocoaPods

#

# We recommend against adding the Pods directory to your .gitignore. However

# you should judge for yourself, the pros and cons are mentioned at:

# http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control

#

# Pods/" > .gitignore

2)通過ls -la查看,可以看到生成了一個.gitignore文件

3)執行如下命令,將.gitignore添加到代碼庫

$ git add .gitignore

$ git commit .gitignore -m “添加.gitignore忽略文件"

6.創建初始化項目

利用Xcode在weibo目錄下創建項目,注意當我們選擇保存地址進入weibo目錄時,Create Git repository 選項卡編程灰色了。

編寫和修改代碼後,選擇Source Control ——->Commit 提交我們的代碼:

在彈出的界面中進行操作,參考圖中說明:

上圖中我沒有選擇自動推送,在項目開發中為了節約時間,可以勾選此項,這裡不勾選是為了告訴大家如何手動推送:選擇SourceControl ——> push

然後點擊push

如果推送成功,會顯示push successful,這就代表推送到遠程倉庫成功。

至此,項目經理初始化項目倉庫就完成了。

員工jackie著手繼續開發項目

創建員工jackie目錄

/Users/hujh/Desktop/GitTest2/jackie

2.進入員工jackie的目錄

cd /Users/hujh/Desktop/GitTest2/jackie

3.”克隆"代碼庫到本地

$ git clone /Users/hujh/Desktop/GitTest2/GitServer/weibo/

就可以在jackie目錄下看到項目文件了

然後就可以開發項目了。

GitHub 教程系列文章

GitHub 使用教程圖文詳解 http://www.linuxidc.com/Linux/2014-09/106230.htm

Git 標簽管理詳解 http://www.linuxidc.com/Linux/2014-09/106231.htm

Git 分支管理詳解 http://www.linuxidc.com/Linux/2014-09/106232.htm

Git 遠程倉庫詳解 http://www.linuxidc.com/Linux/2014-09/106233.htm

Git 本地倉庫(Repository)詳解 http://www.linuxidc.com/Linux/2014-09/106234.htm

Git 服務器搭建與客戶端安裝 http://www.linuxidc.com/Linux/2014-05/101830.htm

Git 概述 http://www.linuxidc.com/Linux/2014-05/101829.htm

分享實用的GitHub 使用教程 http://www.linuxidc.com/Linux/2014-04/100556.htm

Ubuntu下Git服務器的搭建與使用指南 http://www.linuxidc.com/Linux/2015-07/120617.htm

Git 的詳細介紹:請點這裡
Git 的下載地址:請點這裡

Copyright © Linux教程網 All Rights Reserved