windows -
1.安裝與設定git
請先抓取putty-installer安裝,或至少抓取plink.exe
http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html
接下來抓取msysgit的安裝檔 ( 選 Git-1.7.11-preview20120704.exe - 安裝git bash )
http://code.google.com/p/msysgit/downloads/list
安裝時,選擇使用Plink,並從putty安裝資料夾或plink.exe所在資料夾點選plink。 (不知其用途)
2.設定與上傳ssh key
git使用ssh tunnel來傳遞原始碼,這個加密通道可以避免原始碼的封包被攔截而竊取。
因此要先產生與上傳ssh key到github,方便之後與伺服器之間的通訊。
在安裝好的git選單中選取git-bash,並輸入
$ ssh-keygen -C “username@email.com” -t rsa
Generating public/private rsa key pair. Enter file in which to save the key (/home/tom/.ssh/id_rsa): <enter> Enter passphrase (empty for no passphrase): <輸入存取此key之密碼,或直接按下enter使用空密碼> Enter same passphrase again: <再一次輸入相同密碼> Your identification has been saved in /home/tom/.ssh/id_rsa. Your public key has been saved in /home/tom/.ssh/id_rsa.pub. The key fingerprint is: 50:43:77:c6:97:af:61:82:dc:ea:9b:6b:67:d4:1b:61 tom@volcano
您的public key就存放在id_rsa.pub裡面,而id_rsa則是private key,請妥善保存以免遺失。
這個key是一對的,private key要存放於家目錄下的.ssh資料夾中。public key則複製後,貼上您github帳號中的SSH Public Keys欄位。注意小心不要複製到空格。
將Public key所有內容複製後貼上您github帳戶底下的 SSH Public Keys 欄位,一次貼上一個(注意,這邊貼上的是public key,另外請注意不要有空格。)
github設定public keys : 點右上角account settings圖示 -> 左邊點SSH Keys -> Add SSH key ( 把上面public key貼上去 )
3.設定github帳號並開啟一個repo
4. 第一次git push 時可能會遇到
No refs in common and none specified; doing nothing.
Perhaps you should specify a branch such as 'master'.
fatal: The remote end hung up unexpectedly
error: failed to push some refs to 'file:///xxxxxxx.git'
這是Git 找不到你要提交的版本了.
解法:
http://blog.csdn.net/viweei/article/details/6163562
$ git push origin master
5. (optional)安裝 Github 介面軟體
https://help.github.com/articles/set-up-git 點 Download GitHub for Windows (家裏電腦不知為何點了沒反應...)
6. 錯誤訊息:
Cloning into 'amp'...
FATAL ERROR: Disconnected: No supported authentication methods available (serve sent: publickey)
fatal: The remote end hung up unexpectedly
重裝git後照 https://help.github.com/articles/generating-ssh-keys 步驟做一次
更多的git安裝配置與錯誤處理: http://wiki.7color.org/git.html
ps. 讓git-bash的git有高亮
Why does git diff on Windows warn that the “terminal is not fully functional”?
http://stackoverflow.com/questions/7949956/why-does-git-diff-on-windows-warn-that-the-terminal-is-not-fully-functional
Can be fixed by adding the following line to ~/.bashrc:
export TERM=msys
Git - how to tell which commit a tag points to
http://stackoverflow.com/questions/1862423/git-how-to-tell-which-commit-a-tag-points-to
Summary: Since there are about 4 almost equally acceptable yet different answers I will summarise all the different ways to skin a tag.
git rev-list $TAG | head -n 1
(thanks mipadi).git rev-list
outputs the commits that lead up to the$TAG
similar togit log
but only showing the SHA1 of the commit. For non-unix heads like myselfhead -n 1
will show the first line of the output, which is the tip of the tag.git show-ref --tags
(thanks Charles Bailey) will show all tags (local and fetched from remote) and their SHA1s.git show-ref $TAG
(thanks Jakub Narębski) will show the tag and its path along with the SHA1.git rev-parse $TAG
(thanks Jakub Narębski) will show the SHA1 of an unannotated tag.git rev-parse --verify $TAG^{commit}
(thanks Jakub Narębski) will show a SHA1 of both annotated and unannotated tags. On Windows usegit rev-parse --verify %TAG%^^^^{commit}
(four hats).cat .git/refs/tags/*
orcat .git/packed-refs
(thanks The MYYN) depending on whether or not the tag is local or fetched from remote.
沒有留言:
張貼留言