资源预览内容
第1页 / 共7页
第2页 / 共7页
第3页 / 共7页
第4页 / 共7页
第5页 / 共7页
第6页 / 共7页
第7页 / 共7页
亲,该文档总共7页全部预览完了,如果喜欢就下载吧!
资源描述
git 學習手冊(一)Git web實作:1. 安裝 Apachsudo apt-get install apache22. 安裝 Gitwebsudo apt-get install gitwebgitweb.cgi 腳本安裝在/usr/lib/cgi-bin/ 中,該目錄為默認 ubuntu 上 apache2 的 cgi-bin 目錄。所以,打開:http:/127.0.0.1/cgi-bin/gitweb.cgi 即可顯示成功運行,只是我們還未將 git項目加入其中。3. 修改配置文件:sudo vi /etc/gitweb.conf將其中的$projectroot 改為存放各個.git 的目錄只是純 view git的內容而已安裝 GIT for windows要在 windows上安裝 Git,目前並沒有太多選擇。我是安裝 msysgit,網路上找都有安裝說明,你在安裝上應該不會有太多困難。記得勾 bash(命令列)和gui,bash 就是命令列操作模式,gui 是圖形操作介面,但個人感覺 git gui不太好用,如果真的不想用命令列,不如安裝 TortoiseGit(著名的烏龜系列),它的 ui相比之下好用很多。目前也只是純 View git log,用 samba連進 linuxGit command 指令Git設定git init 在這個目錄 init git1. git config -global user.name Tsung2. git config -global user.email usernameemail.com3. git config -global color.diff auto # git diff 要顯示顏色4. git config -global color.status auto # git status 要顯示顏色5. git config -global color.branch auto6. git config -global color.log auto # git log -graph 會很漂亮, 感謝日落提供.7. git config -global core.editor vim # 設定 vim為 git-config的 editor8. git config -global -e # 用 editor開啟/.gitconfig 檔,不加-global的話就會開啟$GIT_DIR/config Git 自動忽略檔案 / 目錄設定要自動將某些檔案掠過不 Commit, 要設定 .gitignore 這個檔案. (哪些檔案是不要 commit 進去的) vim .gitignoretmp/*/*log/*config/database.yml 使用 git add . 等, 這些都不會將這些資料列入 commit. (.gitignore 會被列入 commit) Git 新增檔案 git add . # 將資料先暫存到 staging area, add 之後再新增的資料, 於此次 commit 不會含在裡面. git add filename git add modify-file # 修改過的檔案, 也要 add. (不然 commit 要加上 -a 的參數) git add -u # 只加修改過的檔案, 新增的檔案不加入. git add -i # 進入互動模式Git 刪除檔案 git rm filenameGit 修改檔名、搬移目錄 git mv filename new-filenameGit status 看目前的狀態 git status # 看目前檔案的狀態Git Commit git commit git commit -m commit message git commit -a -m commit -message # 將所有修改過得檔案都 commit, 但是 新增的檔案 還是得要先 add. git commit -a -v # -v 可以看到檔案哪些內容有被更改, -a 把所有修改的檔案都 commitGit 產生新的 branch git branch # 列出目前有多少 branch git branch new-branch # 產生新的 branch (名稱: new-branch), 若沒有特別指定, 會由目前所在的 branch / master 直接複製一份. git branch new-branch master # 由 master 產生新的 branch(new-branch) git branch new-branch v1 # 由 tag(v1) 產生新的 branch(new-branch) git branch -d new-branch # 刪除 new-branch git branch -D new-branch # 強制刪除 new-branch git checkout -b new-branch test # 產生新的 branch, 並同時切換過去 new-branch # 與 remote repository 有關 git branch -r # 列出所有 Repository branch git branch -a # 列出所有 branchGit checkout 切換 branch git checkout branch-name # 切換到 branch-name git checkout master # 切換到 master git checkout -b new-branch master # 從 master 建立新的 new-branch, 並同時切換過去 new-branch git checkout -b newbranch # 由現在的環境為基礎, 建立新的 branch git checkout -b newbranch origin # 於 origin 的基礎, 建立新的 branch git checkout filename # 還原檔案到 Repository 狀態 git checkout HEAD . # 將所有檔案都 checkout 出來(最後一次 commit 的版本), 注意, 若有修改的檔案都會被還原到上一版. (git checkout -f 亦可) git checkout xxxx . # 將所有檔案都 checkout 出來(xxxx commit 的版本, xxxx 是 commit 的編號前四碼), 注意, 若有修改的檔案都會被還原到上一版. git checkout - * # 恢復到上一次 Commit 的狀態(* 改成檔名, 就可以只恢復那個檔案)
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号