window上使用GIT的個人經驗(入門級)

 0.安裝

使用google上的msysgit 

http://code.google.com/p/msysgit/downloads/list 

儘量用最新版的吧 

1.KEY

關於 key,.ssh裏面的key是與服務器通信用的,其他什麼用,也不一定要用email,其實隨便用什麼都可以。

github.com上那個

ssh-keygen -t rsa -C "email"

有誤導的成分,其實引號裏面的不一定要email隨便都可以,只要把本地.ssh/id_rsa.pub裏面的東西複製到github裏面的public ssh key就可以了。

2.大小區分的問題

開始在github上建了個項目,在本地使用了$ git  remote add [email protected]:{user}/{project}.git,結果因爲輸入是大小寫跟服務器上不一致,導致找不到項目,鬱悶啦,最鬱悶的是,在windows上重新按正確的大小寫add一次,提示已經存在,最後的解決辦法是先刪除,然後在添加

 

git remote rm origin

 3.Bash粘貼

默認情況下Git Bash居然不支持粘貼,在我輸入api key的時候最鬱悶,後來解決方法是在Bash窗口上點右鍵 選擇Properties把QuiteEditMode,InsertMode複選框勾上。

 

 4.使用GitHub.com服務器

開始的時候以爲設置加密就可了,原來還有一個apiKey和用戶輸入

也就是在config裏面配置github.com裏的用戶名和郵箱

$ git config --global github.user "youruser" 

$ git config --global github.token yourtoken(在GitHub上的account settings>account admin >>api token那串字符)

配置好了,可以通過

$git config --list查看。

 

5.關於VIM窗口 

開始用git commit 提交的時候是用 -m “message”的

後來直接用git commit 回車後彈出一個窗口,後來才知道是linux下的文本編輯器

鬱悶的是半天退出不出來,baidu,google一番,

進入之後是VIM的普通模式,按 鍵,進入INSERT模式,這是可以輸入message了。

輸入完成之後,按ESC鍵進入命令模式 ,輸入冒號(在窗口下面顯示),然後輸入x,回車就OK了。

 

其實可以用記事本代替vim,

輸入如下配置:

git config --global core.editor C:/windows/notepad.exe 

 

6.清楚Bash裏面的歷史記錄

其實就是Linux清楚歷史命令,直接輸入$ history -c 

 

7.關於Tag

打tag很簡單,所謂“會者不難難者不會”,直接使用git  tag -a tagname -m“mesage”

打完tag要顯示的push,使用命令git push origin tangname,這樣別人才能看到

切換到tag下面用git checkout tagname, 

刪除tag:git tag -d tagname

遠程刪除:git push origin :refs/tags/tagname

 

8.關於Branch

git branch 不帶參數:列出本地已經存在的分支,並且在當前分支的前面加“*”號標記

git branch -r 列出遠程分支

git branch -a 列出本地和遠程分支

git branch BranchName 創建新的 本地 Branch

git branch -d Branchname 刪除branch

git branch -d -r Branchname 刪除遠程branch(例git branch -d -r origin/aa)

git push <remote repository> <local branch> 把本地branch 推送到遠程服務器

 

error: dst refspec notmaster matches more than one.

That's because I had a tag with the same name as the branch. This was a poor choice on my behalf and caused the ambiguity. So in that case:

$ git push origin :refs/heads/notmaster
http://stackoverflow.com/questions/2003505/how-do-i-delete-a-git-branch-both-locally-and-in-github

 

 

9.關於GITK

推薦一篇好的文章

http://lostechies.com/joshuaflanagan/2010/09/03/use-gitk-to-understand-git/ 

 

10.返回命令窗口 

以前一直很鬱悶,輸入了git log之後不知道怎麼返回到命令窗口,就直接關閉整個窗口,

今天用git show tagname也出現了這個問題,經過摸索發現其實很簡單

輸入q,其他鍵盤會繼續顯示剩餘log(如果有的話)

也就是Linux的退出命令 

 

11.文件還原

用了一段時間發現文件還原很重要,之前不知道怎麼弄,裝了TortoiseGit用上面的Revert菜單。

其實用GIT命令是這樣滴:

a,如果文件修改了但是沒有提交(commit),直接用git checkout -f

b,如果修改了並提交了,

可以用 git revert HEAD

可以用git reset --hard HEAD 

 

fatal: git clone could not read password for

git config --global core.askpass /usr/libexec/git-core/git-gui--askpass
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章