顯示具有 git 標籤的文章。 顯示所有文章
顯示具有 git 標籤的文章。 顯示所有文章

2011年12月8日 星期四

git - 在windows環境下使用_netrc來存帳號密碼

之前寫了一篇文章記錄如何在windows環境上裝git server

基本上,依照這篇設定的方式
git client端在pull、push程式時
因為是透過http basic authentication來做帳號密碼的認證的

時間一久,工程師對於重覆的動作是會煩的
來用_netrc檔案來記憶UserName和Password吧
步驟如下:
1.透過cmd.exe來設定環境變數HOME
設定好之後,將命令視窗關掉,再重新執行後打上echo %HOME%來看一下設定後的路徑在哪
通常都是C:\Users\"你的帳號"

2.建一個_netrc檔,放到剛剛echo出來的%HOME%路徑裡
_netrc檔的內容如下:


machine <server name>
login <username>
password <password>


<server name>就是遠端的git repository的路徑
<username>就是http認證的帳號
<password>當然就是密碼

3.就是pull程式試看看吧 XD

2011年8月23日 星期二

git server on windows記錄

*安裝apache

*安裝git

*將git安裝目錄的bin\libiconv2.dll 和 libiconv-2.dll  複製到 libexec\git-core\ 下

*在D槽新增GitRepos,用來放git repository

*修改apache的httpd.config
修改Directory區塊如下

<Directory />
    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Allow from all
</Directory>


在最後面加入
#Set this to the root folder containing your Git repositories.
SetEnv GIT_PROJECT_ROOT D:/GitRepos
# Set this to export all projects by default (by default,
# git will only publish those repositories that contain a
# file named “git-daemon-export-ok”
SetEnv GIT_HTTP_EXPORT_ALL
# Route specific URLS matching this regular expression to the git http server.
#若git的存放路徑不同,記得修改最後一行
ScriptAliasMatch \
  "(?x)^/(.*/(HEAD | \
    info/refs | \
    objects/(info/[^/]+ | \
      [0-9a-f]{2}/[0-9a-f]{38} | \
      pack/pack-[0-9a-f]{40}\.(pack|idx)) | \
    git-(upload|receive)-pack))$" \
    "C:/Program Files (x86)/Git/libexec/git-core/git-http-backend.exe/$1"
<Location "/">
    AuthType Basic
    AuthName "GIT Repository"
    AuthUserFile "D:/GitRepos/htpasswd/git.passwd"
    Require valid-user       
</Location>

*產生git.passwd
在命令列下,切換到apache底下的bin目錄
key下面指令: htpasswd -c git.passwd 使用者名稱
之後會要你輸入密碼
若要再產生另外一個帳號到同一個檔案
則輸入htpasswd -m git.passwd 使用者名稱
之後把bin目錄下的git.passwd搬到D:/GitRepos/htpasswd/

*重啟apache

*使用git的bash到D:/GitRepos
  git init --bare --share TestProject
  再切換到TestProject
  git update-server-info

*之後就從client抓資料啦