gitManaged 程式碼(一)

來源:互聯網
上載者:User

久聞git大名,但是一直不知道為何物。現在認真的過了一遍。原來是和svn一樣的版本控制器。

具有速度快,分布式管理等優點。

現在就來看看git的使用過程,我這裡是用開源中國來Managed 程式碼的,如果是使用github也是一樣的。

1 先下載git for windows

然後一直點下一步安裝.

2 安裝之後,選擇git gui.產生ssh 連結 git 公開金鑰.

用命令也可以:

$ ssh-keygen -t rsa -C "your_emali@youemal.com"

然後輸入密碼.

建議用第一種方式。第二種網上說是可以,但是我沒成功過。

然後輸入密碼。

3 將公開金鑰添加到開源中國上,或者是github中

在開源中國中建立一個公開金鑰,然後將.ssh檔案夾下的id_ras_pub中的內容複寫到文字框中,這裡的title可以隨意.

4 測試連結:

輸入命令:$ ssh -T git@git.oschina.net

然後輸入yes

如果成功可以看到你的使用者名稱和郵箱.

出現錯誤可以測試:$ ssh -Tv git@git.oschina.net

5 設定使用者名稱和郵箱

$ git  config user.name"you name"

$git  config user.email"you_email@youemal.com"

6 然後在web開源中國中建立一個project.

7 測試上傳檔案

 建立檔案夾,需要和你建立的projexct同名。

mkdir hello

cd hello

git init

touch README

git add README

git commit  -m  'frist commit'

8 提交

git remote add test git@git.oschina.net:web使用者名稱/hell.git

git push -u test master

如裡有報錯誤:

To git@git.oschina.net:yangzhi/hello.git ! [rejected]        master -> master (fetch first)error: failed to push some refs to 'git@git.oschina.net:yangzhi/hello.git'hint: Updates were rejected because the remote contains work that you dohint: not have locally. This is usually caused by another repository pushinhint: to the same ref. You may want to first merge the remote changes (e.g.hint: 'git pull') before pushing again.hint: See the 'Note about fast-forwards' in 'git push --help' for details.

可以輸入:

git push -f 

可以ok了.

10 複製代碼

git clone git@github..com:使用者名稱/項目名.git

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.