git 如何通过终端编辑 .gitignore 文件/更改 .gitignore 文件规则
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/40296807/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to edit .gitignore file/change .gitignore file rules through Terminal
提问by Allison
I'm new to Git.. I created a .gitignore file and added a line of folder name into the .gitignore file. Now I'm wondering if I want to make a change to the line where i specified the directory name, how should I achieve this, especially how to do this through Mac terminal? Thanks in advance!
我是 Git 的新手。我创建了一个 .gitignore 文件,并在 .gitignore 文件中添加了一行文件夹名称。现在我想知道是否要对指定目录名称的行进行更改,我应该如何实现这一点,尤其是如何通过 Mac 终端来做到这一点?提前致谢!
回答by Mauricio Machado
That can be done using the vim editor.
Simply type vi [path-to-file]\file
and you will open the vim terminal editor.
There's a lot (like a LOT) you can do with vim, but for your purposes:
这可以使用 vim 编辑器来完成。只需键入vi [path-to-file]\file
,您将打开 vim 终端编辑器。你可以用 vim 做很多(比如很多),但为了你的目的:
- Press
a
to toggle the edit mode - Edit stuff
- Press
Esc
to finish edit mode and toggle the command mode - Press/type
:
to indicate you want to type a command - Type and enter
wq
to save the changes and exit
- 按下
a
可切换编辑模式 - 编辑内容
- 按
Esc
完成编辑模式并切换命令模式 - 按/键入
:
以指示您要键入命令 - 输入并回车
wq
以保存更改并退出
I'm sorry if I'm "overdetailing" this steps but my first encounters with vim were a little unfortunate and closing the editor properly is not a trivial task.
很抱歉,如果我“过度详细”了这些步骤,但我第一次遇到 vim 有点不幸,正确关闭编辑器并不是一项微不足道的任务。
Good luck!
祝你好运!