我有一些曾经在git存储库中的文件但后来被忽略了。 (主要是配置文件)但是,当我运行git reset --hard
时,这些忽略文件的更改也会重置,我确定头版本已经忽略了这些文件。
这是正常的吗?有没有办法让git reset --hard
忽略忽略文件的更改?
答案 0 :(得分:2)
如果您已提交文件并在之后忽略它,则必须在单独的提交中再次删除该文件。
之后仍然想要使用该文件时,您应事先备份它们。
var questionBank= ["questionText", "questionText1", "questionText2"];
document.getElementById("btnDeleteQuestion").addEventListener("click", function() {
// index get by text
const index = questionBank.indexOf("questionText");
if(index!=-1){
//Delete element by index
questionBank.splice(index, 1);
}
console.log(questionBank);
});
您可以删除忽略的文件:
cp <file> <file>.bak
有关详细信息,请查看此question。
答案 1 :(得分:0)
您还可以使用git clean删除所有忽略的文件:
.gitignore中有文件时,将不考虑它们 更改,但您仍可能希望摆脱这些更改,例如因为 它们会使您的文件系统混乱。
尽管常规git clean也将忽略它们,并传递-x 切换更改:
private void onRecycler(String response){ try { //getting the whole json object from the response JSONObject obj = new JSONObject(response); if(obj.optString("status").equals("200")){ ArrayList<ModelRecycler> modelRecyclerArrayList = new ArrayList<>(); JSONArray dataArray = obj.getJSONArray("data"); for (int i = 0; i < dataArray.length(); i++) { ModelRecycler modelRecycler = new ModelRecycler(); JSONObject dataobj = dataArray.getJSONObject(i); modelRecycler.setImageURL(dataobj.getString("imageURL")); modelRecycler.setCategoryTitle(dataobj.getString("categoryTitle")); modelRecycler.setNumber(dataobj.getString("number")); modelRecycler.setTitle1(dataobj.getString("title1")); modelRecycler.setTitle2(dataobj.getString("title2")); modelRecyclerArrayList.add(modelRecycler); } retrofitAdapter.notifyDataSetChanged(); //Add this line here. } catch (JSONException e) { e.printStackTrace(); }
如果您想先看看会发生什么,请确保通过-n 进行空转:
git clean -x
通过-f进行更彻底的清洁(在某些情况下强制清洁 情况;我认为默认情况下也是必需的)或-d (删除目录)开关:
git clean -xn
小心:您可能会忽略本地配置文件,例如database.yml 也将被删除。使用风险自负。