2017-02-17 446 views
0

我使用Ubuntu OS,我試圖執行git的命令如下:git的命令輸出到文件

git clone -v https://senuser:[email protected]/senxxxx/xxxxx.git > /home/ubuntu/output1.txt 2>&1. 

但輸出顯示:

[email protected]:~ [04:24:16]$ more output1.txt 
Cloning into 'xxxxxxx'... 
POST git-upload-pack (252 bytes) 
[email protected]:~ [04:24:24]$ 

但是,如果我手動執行命令我得到如下:

[email protected]:~ [03:28:36]$ sh testgitpull.sh 
Cloning into 'xxxxxxaws'... 
Password for 'https://[email protected]': 
remote: Counting objects: 56, done. 
remote: Compressing objects: 100% (40/40), done. 
remote: Total 56 (delta 18), reused 0 (delta 0) 
Unpacking objects: 100% (56/56), done. 
Checking connectivity... done. 
[email protected]:~ [03:28:48]$ 

有人可以請幫助如何獲得上述種類的輸出,而不是2行?

回答

0

爲什麼不用下面的命令?

git clone -v https://senuser:[email protected]/senxxxx/xxxxx.git &> /home/ubuntu/output1.txt 

有關詳細信息,請參閱what-does-devnull-21-mean

+0

嗨,當我跑這樣我下面有,但沒有我的輸出裏面。 ubuntu $ sh testgitpull2.sh 克隆到'rydetestaws'中... POST git-upload-pack(240字節) remote:計數對象:56,完成。 遠程:壓縮對象:100%(40/40),完成。 遠程:總計56(增量18),重用0(增量0) 解包對象:100%(56/56),完成。 檢查連接...完成。 ubuntu @ ryde-dev:〜[08:18:41] $ more output1.txt ubuntu @ ryde-dev:〜[08:18:52] $。但是我需要output1.txt文件中的詳細信息。 – Senthil