Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I create a text file and add text to it in Git Bash?

Tags:

git-bash

How do I create a text file and add text to it in Git Bash?

Is there a command for that operation?

like image 788
janice4928 Avatar asked Oct 21 '25 12:10

janice4928


2 Answers

In git bash, the simplest way to create/write a file is:

echo "some text" > aNewFile

Then you can edit it:

vi aNewFile
like image 102
VonC Avatar answered Oct 23 '25 07:10

VonC


you can create any new file by using any Editor's command.

Now, there are many editors for git : vi, nano, gedit, etc.. Typing

nano hey.txt 

or

vim hey.txt

will create new hey.txt in the git repository folder(if not already created) and will open the editor for you to edit your .txt file in simple text. Then save it and you are done !

like image 41
Jasnoor Singh Brar Avatar answered Oct 23 '25 07:10

Jasnoor Singh Brar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!