不錯的git筆記博客:
http://www.cnblogs.com/wanqieddy/category/406859.html
http://blog.csdn.net/zxncvb/article/details/22153019
Git學習教程(六)Git日志
http://fsjoy.blog.51cto.com/318484/245261/
圖解git
http://my.oschina.net/xdev/blog/114383
Git詳解之三:Git分支
http://blog.jobbole.com/25877/
情況一、
svn: /opt/svndata/repos/conf/svnserve.conf:12: Option expected
權限配置:
#分組:
[groups]
group_admin = wws,aaa,bbb
group_user1 = sj,ccc
group_user2 = sy,dd,eeee
group_user3 = lxt
group_user4 = ss
#設置對根(即SVN)目錄下,所有版本庫的訪問權限
[/]
* = r #所有登錄用戶默認權限為只讀
@group_admin = rw #可以分配給組,該組有讀寫權限
wws = rw #也可以像這樣分配給指定用戶
在修改配置文件(authz)后,客戶端可能會報“Invalid authz configuration”的錯誤提示!
客戶端沒有提示錯誤原因,但在服務器端有一個方法,可以檢查配置文件(authz)錯在了哪里;
具體方法如下:
root@server:~# svnauthz-validate /data/svn/LQPLAY/conf/authz
svnauthz-validate: /data/svn/LQPLAY/conf/authz:167: Option must end with ':' or '='
它查出了是配置文件(authz)的第167行,出現了錯誤。
然后,可以用如下命令,編輯它並保存:
root@server:~# vi /data/svn/LQPLAY/conf/authz
Shift+: set number (顯示行號)
Shift+: 167 (直接跳轉到167行)
我發現是本該寫為(gaojs = rw),不小心寫成了(gaojs - rw)。
字母鍵(I-Insert),從瀏覽模式,切換到插入模式;
(Shift+:, 從瀏覽模式,切換到底行命令模式)
(Esc,從其他模式,退出到瀏覽模式)
修改后保存退出!
Shift+: wq (Write & Quit)
情況二、SVN的“Invalid authz configuration”錯誤的解決方法
轉自:http://blog.csdn.net/gaojinshan/article/details/18218009
查看SVN的目錄在哪里?
root@server:~# whereis svn
svn: /usr/bin/svn /usr/bin/X11/svn /usr/share/man/man1/svn.1.gz
查看SVN的進程是哪些?
root@server:~# ps aux | grep svn
root 1527 0.0 0.0 69640 1092 ? Ss 10:53 0:00 svnserve -d -r /data/svn/LQPLAY
root 5144 0.0 0.0 13592 936 pts/2 S+ 11:58 0:00 grep --color=auto svn
啟動SVN的服務(-d:Deamon; -r:Root)
root@server:~# svnserve -d -r /data/svn/LQPLAY
查看SVN的服務是否正常(端口號3690是否存在)
root@server:~# netstat -ntlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:3690 0.0.0.0:* LISTEN 1527/svnserve
1、checkout時,提示:URL svn://192.168.1.99/svntest doesn't exist...
奇怪,怎么會提示庫不存在呢?肯定是哪里配置問題。后來嘗試了半天,也在網上搜索了很久,終於發現問題所在。
如果你的svn庫的路徑為:/home/svn/svntest
那么你啟動時,不能用命令:
svnserve -d -r /home/svn/svntest
而要用命令:
svnserve -d -r /home/svn/
2、commit時,提示:Authorization failed
開始一直以為是authz文件配置得不對,一直嘗試,一直修改,還是不行,郁悶了。在確定authz的配置完全沒問題后,開始查其它兩個配置文件的問題。后來終於發現問題出在svnserve.conf這個文件。以下四行:
# anon-access = read # auth-access = write # password-db = passwd # authz-db = authz
是被注釋掉的,雖然文件說明里面說默認就是按注釋掉的配置來執行,但好像並不是這樣。放開注釋:
anon-access = read auth-access = write password-db = passwd authz-db = authz
問題解決。
PS:有些童鞋問文件上傳到服務器后存放在服務器的哪個地方。
答:一般放在/home/svn/svntest/db/revs(根據我自己的目錄結構)里面
svn: No repository found in 'svn:..解決方案
svn服務未啟動或者是啟動的時候未指定svn倉庫路徑
使用如下命令:
sudo svnserve -d -r /var/svn
后面的目錄是你svn服務的倉庫路徑
另外要使用sudo取得管理員權限,否則可能在提交代碼的時候出現權限問題
1、git commit
此時是進入GUN nano編輯器。在這里可以添加你的commit imformation 然后ctrl+o,回車保存,再ctrl+x退出。
因為對Nano編輯器很不熟悉,在這里我想將默認編輯器改為vim。打開.git/config文件,在core中添加 editor=vim即可。
或者運行命令 git config –global core.editor vim 修改更加方便。
2、git commit -a
把所有add了的文件都加入commit,然后進入編輯器編輯commit信息。
3、git commit -m “commit imformation”
直接在后面添加commit 信息然后提交commit,與gitcommit相比快捷方便,但是就是commit信息格式無法控制。
4、git commit --amend
修改最后一次commit的信息
git config運用
"remote:error:refusing to update checked out branch:refs/heads/master"的解決辦法
在使用Git Push代碼到數據倉庫時,提示如下錯誤:
[remote rejected] master -> master (branch is currently checked out)
錯誤原型
remote: error: refusing to update checked out branch: refs/heads/master
remote: error: By default, updating the current branch in a non-bare repository
remote: error: is denied, because it will make the index and work tree inconsistent
remote: error: with what you pushed, and will require 'git reset --hard' to match
remote: error: the work tree to HEAD.
remote: error:
remote: error: You can set 'receive.denyCurrentBranch' configuration variable to
remote: error: 'ignore' or 'warn' in the remote repository to allow pushing into
remote: error: its current branch; however, this is not recommended unless you
remote: error: arranged to update its work tree to match what you pushed in some
remote: error: other way.
remote: error:
remote: error: To squelch this message and still keep the default behaviour, set
remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.
To git@192.168.1.X:/var/git.server/.../web
! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to 'git@192.168.1.X:/var/git.server/.../web'
解決辦法:
這是由於git默認拒絕了push操作,需要進行設置,修改.git/config文件后面添加如下代碼:
[receive]
denyCurrentBranch = ignore
無法查看push后的git中文件的原因與解決方法
在初始化遠程倉庫時最好使用
git --bare init
而不要使用:git init
git init 和git --bare init 的具體區別:http://blog.haohtml.com/archives/12265
=================================================
如果使用了git init初始化,則遠程倉庫的目錄下,也包含work tree,當本地倉庫向遠程倉庫push時, 如果遠程倉庫正在push的分支上(如果當時不在push的分支,就沒有問題), 那么push后的結果不會反應在work tree上, 也即在遠程倉庫的目錄下對應的文件還是之前的內容。
解決方法:
必須得使用命令 git reset --hard 才能看到push后的內容.
研究了很久不得其解,然后找到一條命令湊合着能用了:
git config --bool core.bare true
就搞定了。
貼一段參考文章:
Create a bare GIT repository
A small rant: git is unable to create a normal bare repository by itself. Stupid git indeed.
To be precise, it is not possible to clone empty repositories. So an empty repository is a useless repository. Indeed, you normally create an empty repository and immediately fill it:
git init git add .
However, git add is not possible when you create a bare repository:
git --bare init git add .
gives an error "fatal: This operation must be run in a work tree".
You can't check it out either:
Initialized empty Git repository in /home/user/myrepos/.git/ fatal: http://repository.example.org/projects/myrepos.git/info/refs not found: did you run git update-server-info on the server? git --bare init git update-server-info # this creates the info/refs file chown -R <user>:<group> . # make sure others can update the repository
The solution is to create another repository elsewhere, add a file in that repository and, push it to the bare repository.
mkdir temp; cd temp git init touch .gitignore git add .gitignore git commit -m "Initial commit" git push <url or path of bare repository> master cd ..; rm -rf temp
轉自:http://blog.csdn.net/rainysia/article/details/49463753
昨天打算把git diff 關聯上bcompare作兩個文件對比, 后來發現不怎么好用. 還要彈個gtk的窗口. 於是unset了后.
今天重新git diff的時候, 發現輸入后沒有任何反應. 就記錄下怎么修復的
找了一台可以用git diff的機器, 隨便echo 了一個多余的字符進已有的repository, 這里我們用strace來追蹤執行過程.
#strace -f -e execve git diff
execve("/usr/bin/git", ["git", "diff"], [/* 45 vars */]) = 0 Process 27865 attached [pid 27865] execve("/usr/lib/git-core/pager", ["pager"], [/* 49 vars */]) = -1 ENOENT (No such file or directory) [pid 27865] execve("/usr/local/bin/pager", ["pager"], [/* 49 vars */]) = -1 ENOENT (No such file or directory) [pid 27865] execve("/usr/bin/pager", ["pager"], [/* 49 vars */]) = 0 diff --git a/fabfile.py b/fabfile.py index e53e07a..0974ee9 100644 --- a/fabfile.py +++ b/fabfile.py @@ -176,3 +176,4 @@ def test(version='', by='TAG'): _push_rpm(rpmfile=rpmfile) # done return +122 [pid 27865] +++ exited with 0 +++ --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=27865, si_uid=1000, si_status=0, si_utime=0, si_stime=0} --- +++ exited with 0 +++
再看看不能執行的
#strace -f -e execve git diff
execve("/usr/bin/git", ["git", "diff"], [/* 44 vars */]) = 0 Process 20460 attached [pid 20460] execve("/usr/lib/git-core/less", ["less"], [/* 47 vars */]) = -1 ENOENT (No such file or directory) [pid 20460] execve("/usr/local/bin/less", ["less"], [/* 47 vars */]) = -1 ENOENT (No such file or directory) [pid 20460] execve("/usr/bin/less", ["less"], [/* 47 vars */]) = 0 [pid 20460] +++ exited with 0 +++ --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=20460, si_uid=1000, si_status=0, si_utime=0, si_stime=0} --- +++ exited with 0 +++
原來是正常的pager給換成了less.
這就簡單了,找了下/etc/gitconfig. /root/.gitconfig, /home/username/.gitconfig 以及項目下的.git/config 都沒有發現alias pager=less的. 看看git config –list 也沒有定義.
想起來改過bashrc, 打開一看, 果然
export PAGER=less
刪掉后重新加載terminal, git diff就恢復了正常.
Double Hyphens in Git Diff
Two months ago, I wrote my first list of Git commands, and said that I didn’t know how to use Git commands to view the changes.1
Now, I can understand how one can “use ‘--
’ to separate paths from revisions [or branches]”.
For example, if a developer relies on this Git cheatsheet for blogging with Octopress, then he/she will learn some Git commands, for example:
git diff <branch>
to view the uncommitted changes;git diff <path>
to show the uncommitted changes in files under<path>
.
Those commands should be enough for most cases. However, if he/she blogs with Octopress, then he/she will encounter the some problems:
git diff source
can’t view the uncommitted changes onsource
branch; (Click the linked post in footnote 1 for the error thrown by Git.)git diff source
can’t show the uncommitted changes in files undersource
folder.
In order to use git diff
to do the intended task, one has to avoid ambiguity.
- If necessary, one can use
--
to separate branch name(s) from file/path names; - 一個可以使用
./source
到平均source
文件夾。
$ git diff origin/source source fatal: ambiguous argument 'source': both revision and filename Use '--' to separate paths from revisions, like this: 'git <command> [<revision>...] -- [<file>...]' $ git diff origin/source source -- # correct command $ git diff ./source # correct command
如果一個想要在 shell 命令中鍵入,其中一個可以考慮使用fugitive.vim: 在一個窗口由調用:Gst
,在修改后的文件在哪里顯示的線按D
。
將本地test分支push到遠程倉庫上,如果遠程沒有就會創建
git push origin test
git checkout test -------》將遠程的test分支下載到本地
git checkout -b aa origin/test -----》 將遠程的test分支下載到本地,並且切換到本地