我正在使用以下命令使用兩點方法獲取兩個分支之間的差異。
git diff master..hotfix_master
在 gitlab 管道中,使用相同的命令,它失敗了
> $ git diff hotfix_master..master fatal: ambiguous argument
> 'hotfix_master..master': unknown revision or path not in the working
> tree. Use '--' to separate paths from revisions, like this: 'git
> <command> [<revision>...] -- [<file>...]'
但是從本地筆記本電腦,它可以作業。
我從字面上無法理解,這是什么問題。
我需要在某處使用轉義字符嗎?
請建議
編輯 1:
即使在放置后origin,它也不起作用。
$ git diff origin/hotfix_master..origin/master
fatal: ambiguous argument 'origin/hotfix_master..origin/master': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
編輯:2
$ pwd
/builds/irfanjs1/blank-proj
$ ls -al
total 28
drwxrwxrwx 3 root root 4096 Dec 13 15:09 .
drwxrwxrwx 4 root root 4096 Dec 13 15:09 ..
drwxrwxrwx 6 root root 4096 Dec 13 15:09 .git
-rw-rw-rw- 1 root root 445 Dec 13 15:09 .gitlab-ci.yml
-rw-rw-rw- 1 root root 7583 Dec 13 15:09 README.md
-rw-rw-rw- 1 root root 13 Dec 13 15:08 a.txt
$ dir
README.md a.txt
$ git diff origin/hotfix_master..origin/master
fatal: ambiguous argument 'origin/hotfix_master..origin/master': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
編輯 3
$ pwd
/builds/irfanjs1/blank-proj
$ ls -al
total 28
drwxrwxrwx 3 root root 4096 Dec 13 15:55 .
drwxrwxrwx 4 root root 4096 Dec 13 15:54 ..
drwxrwxrwx 6 root root 4096 Dec 13 15:55 .git
-rw-rw-rw- 1 root root 494 Dec 13 15:55 .gitlab-ci.yml
-rw-rw-rw- 1 root root 7583 Dec 13 15:55 README.md
-rw-rw-rw- 1 root root 13 Dec 13 15:54 a.txt
-rw-rw-rw- 1 root root 0 Dec 13 15:55 b.txt
$ dir
README.md a.txt b.txt
$ git branch
* (HEAD detached at 486173f)
$ git branch -r
origin/master
$ git diff origin/hotfix_master..origin/master
fatal: ambiguous argument 'origin/hotfix_master..origin/master': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
編輯 4
$ dir
README.md a.txt b.txt
$ git branch
* (HEAD detached at 87eb7a5)
$ git branch -r
origin/master
$ git fetch
From https://gitlab.com/irfanjs1/blank-proj
* [new branch] hotfix_master -> origin/hotfix_master
* [new branch] main -> origin/main
$ git diff origin/hotfix_master...origin/master
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index ddf5df3..5b149d0 100644
--- a/.gitlab-ci.yml
b/.gitlab-ci.yml
@@ -25,6 25,9 @@ merge-to-master:
- "pwd"
- "ls -al"
- "dir"
- - "git diff origin/hotfix_master..origin/master"
- "git branch"
- "git branch -r"
- "git fetch"
- "git diff origin/hotfix_master...origin/master"
uj5u.com熱心網友回復:
TL; 博士
將您的 Git“深度”設定為零;請參閱
該git diff命令從一個新創建的目錄運行,但尚未添加到 git 中(未暫存):

該命令針對不存在的分支運行:

對于第一種和第二種情況,解決方案只是退出您被忽略的目錄并在父檔案夾中運行 git 命令。
對于第三種情況,在對它們運行 diff 之前確保分支存在。git fetch在比較遠程分支之前也不要忘記做。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/380590.html
標籤:混帐 GitLab gitlab-ci git-diff
