我在終端會話中添加文本檔案 .gitignore 時遇到問題。我打開命令列提示符并導航到包含 .gitignore 檔案和 hello_git.py 檔案的檔案夾。
當我輸入 git status 時;Python 檔案顯示出來,但沒有顯示 .gitignore。我可以通過輸入 git add 來添加 Python 檔案。另一個檔案不會添加或提交。
我應該怎么做才能使用 .gitignore 檔案?
uj5u.com熱心網友回復:
如果您對它感興趣,這里是關于如何在所有專案中全域使用相同的 gitignore 的快速介紹,因為您的解釋不太深入:
touch ~/.gitignore_global # This creates a global.gitignore file in the current directory.
git config --global core.excludesfile ~/.gitignore_global # This command will override all patterns in /.gitignore global in all situations.
# Following this do not forget to edit the .gitignore_global
但是,據我所知,您不能推送自己的 .gitignore 檔案。鑒于此,我希望您仔細檢查內容是否為空,如果是,請在查看您的 git 狀態之前更新它(正如@evolutionxbox 也所述)。此外,嘗試將其包含在您的提交中;如果這不起作用,您可以強制執行它,但這絕不是一個很好的建議:
git add --force [...]/.gitignore
#
# Man git add:
# -f, --force Allow adding otherwise ignored files.
# https://git-scm.com/docs/git-add
#
干杯,我希望這會有所幫助;如果解決方案適合您,請記住同意該解決方案。度過美好的一天,
西蒙。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/332858.html
標籤:混帐
