騰訊域名怎么做網(wǎng)站網(wǎng)絡(luò)推廣深圳有效渠道
最新在整理代碼時發(fā)現(xiàn),local.properties文件開頭有這么一段注釋:
## This file must *NOT* be checked into Version Control Systems,
# as it contains information specific to your local configuration.
大意是這個文件不要加入到版本管理中。
之前一直沒留意這段注釋,現(xiàn)在該文件已經(jīng)加到Git版本管理中了。于是通過資詢Gemini,找到了解決辦法。
1、將local.properties加入到.gitignore文件中。
打開.gitignore,加入下面最后一行內(nèi)容,并保存。
/app/build/
/app/build/intermediates/javac/debug/classes/
/app/release/
/local.properties
2、在Android Studio中打開終端(Terminal)窗口。執(zhí)行下面的指令:
git rm --cached local.properties
這樣就會刪除本地Git庫(repository)中的文件。
然后提交修改,并添加注釋:
git commit -m "Remove local.properties from version control"
-m 后面就是注釋內(nèi)容,你可以錄入自己需要的內(nèi)容。
3、如果還需要將修改提交到遠程Git服務(wù)器。有兩種方法,使用其中之一就可以。
方法一:使用命令行
執(zhí)行下面的指令:
git push <repository_name> <branch_name>
repository_name表示Git庫(repository)名稱,branch_name表示默認分支名稱。
假設(shè)Git庫名稱為:abc,默認分支名稱為:master。那么實際執(zhí)行的指令為:
git push abc master
需要注意的是,我的項目默認分支名稱是master,不代表你的也是。你的可能是main或其他。
如果想查詢自己的分支名稱,可以使用指令:
git remote show abc
上面的abc是我Git庫(repository)名稱。你要換成自己的庫名稱。
執(zhí)行上面的命令后,我會顯示下面內(nèi)容:
D:\workspace_as\abc>git remote show abc
* remote abcFetch URL: http://aaa@192.168.1.123:23456/r/abc/abc.gitPush URL: http://aaa@192.168.1.123:23456/r/abc/abc.gitHEAD branch: masterRemote branch:master trackedLocal branch configured for 'git pull':master merges with remote masterLocal ref configured for 'git push':master pushes to master (fast-forwardable)
在"HEAD branch"字段后的就是默認分支名稱。上圖中默認分支名稱就是master。
方法二:使用鼠標(biāo)
可以在項目上點擊鼠標(biāo)右鍵,選擇Git>Push,提交即可。
備注:
上面演示了如何刪除文件,如果要刪除目錄,比如要刪除目錄“build”。那么第一步就要將目錄名加入到.gitignore中:
/build
第二步從本地Git庫中刪除的指令為:
git rm -r --cached build
build就是要刪除的目錄名。注意要加-r參數(shù),用來同時刪除目錄下的的所有內(nèi)容。
第三步與刪除文件的第三步相同。