Mac OS鏈接git@git.oschina.net(不囉嗦的傻瓜版)

####請先註冊http://git.oschina.net。 ##環境準備:node

  1. Xcode(直接AppStore下載安裝)
  2. Git(能夠在http://code.google.com/p/git-osx-installer/下載git安裝程序,或者在https://www.kernel.org/pub/software/scm/git/下載源碼安裝。)

###源碼安裝過程:git

  1. 解壓源碼包dom

    tar xjvf git-1.8.3.tar.bz2
  2. 編譯ssh

    cd git-1.8.3
     ./configure --prefix=/usr/local
     make
  3. 安裝ide

    sudo make install

##配置Git並鏈接到git@git.oschina.net 請參見老左的博客Xcode鏈接git@osc中第一步至第四步。工具

##將工程同步到git@git.oschina.netgoogle

  1. 在你的git.oschina.net下「建立項目」。.net

  2. 在你的電腦上,爲了之後管理方便,應該爲OSChina上的項目創建一個文件夾統一管理,例如gitOSChina。在次級目錄下存放每個項目。命令行

  3. 打開命令行工具,執行命令:code

    cd gitOSChina/JBCalendar/			進入項目的目錄
     git init							初始化本地庫(僅第一次時須要)
     git remote add origin git@git.oschina.net:JustBen/jbcalendar.git  添加遠程版本庫的別名
     git add .		添加全部文件到版本庫
     git commit -a -m "commit JBCalendar"	添加全部修改該版本庫
     git pull origin master		從遠程庫獲取併合併到本地庫
     git push origin master		將修改推送到遠程庫
  4. 至此,新建工程完成了。

##更新工程

  1. 相似於建立項目時的操做,打開命令行工具,執行命令

    cd gitOSChina/JBCalendar/			進入項目的目錄
     git add .		添加全部文件到版本庫
     git commit -a -m "commit JBCalendar"	添加全部修改該版本庫
     git pull origin master		從遠程庫獲取併合併到本地庫
     git push origin master		將修改推送到遠程庫
  2. 至此,更新完畢。

##錯誤小結

錯誤:

git pull origin master

ssh: Could not resolve hostname git.oschina.net:JustBen: nodename nor servname provided, or not known
fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.

解決方法:

從新設置SSH

	cd
	cd ~/.ssh/
	ssh-keygen
	
	Generating public/private rsa key pair.
	Enter file in which to save the key (/Users/yongbin/.ssh/id_rsa): 
	/Users/yongbin/.ssh/id_rsa already exists.
	Overwrite (y/n)? y
	Enter passphrase (empty for no passphrase): 
	Enter same passphrase again: 
	Your identification has been saved in /Users/yongbin/.ssh/id_rsa.
	Your public key has been saved in /Users/yongbin/.ssh/id_rsa.pub.
	The key fingerprint is:
	f8:87:a4:25:37:7c:bf:64:b1:4f:d5:e1:27:74:18:9e yongbin@YongbinZhang.local
	The key's randomart image is:

	+--[ RSA 2048]----+
	|              .  |
	|             . + |
	|              E..|
	|       o     ...o|
	|      o S . . ..+|
	|       B + . o o.|
	|      . o . = .  |
	|         . o +   |
	|            . .  |
	+-----------------+


	cat id_rsa.pub | pbcopy		在git.oschina.net中添加一個SSH,直接複製到裏面便可
	
	
	cd ~/OSChina/JBCalendar/	進入工程目錄
	
	git add .
	git commit -a -m "xxxxxxxxxxxxxx"
	git pull origin master
	git push origin master
相關文章
相關標籤/搜索