Skip to content

Instantly share code, notes, and snippets.

@palashmon
Last active February 27, 2024 05:14
Show Gist options
  • Save palashmon/5bd57c75c9b2b1b8af5d5968f13c9da9 to your computer and use it in GitHub Desktop.
Save palashmon/5bd57c75c9b2b1b8af5d5968f13c9da9 to your computer and use it in GitHub Desktop.
Create a new file in git bash

Usage

# You can simply type
> emptyfile.txt

# This will create a empty text file with name "emptyfile"
# This same as doing
echo "" > emptyfile.txt
@patrickmederos
Copy link

what is the touch command?

@MadihaUmar
Copy link

touch emptyfile.txt

what is the touch command?

@Pfed-prog
Copy link

what is the touch command?

the command touch can also create multiple files:
$ touch locator.py page.py

@FabricioSouzaDesign
Copy link

Can I use the touch command in windows prompt?

@Pfed-prog
Copy link

Pfed-prog commented Nov 18, 2020

@ibro20
Copy link

ibro20 commented Jan 11, 2021

Touch does work on Windows and MAC.

@Minhazul-Islam18
Copy link

touch: cannot touch 'first.html': No such file or directory

I need solution

@muhammadfarras
Copy link

touch: cannot touch 'first.html': No such file or directory

I need solution

Where did you run it ?

@MalusiNgubane
Copy link

same here. touch doesn't work

Copy link

ghost commented Feb 4, 2022

how to add a folder in git repo ?

@alsongarbuja
Copy link

how to add a folder in git repo ?

mkdir foldername

it will do it

@Cluaz
Copy link

Cluaz commented Apr 22, 2022

same here. touch doesn't work

It may be your antivirus. If you use windows security, for instance, there is ransomware protection with the option of controlled folder access. If It is on, It will prevent git from creating the file, even if you make git an exception to the rule.

@ayushigeorge
Copy link

how to make file.md in a repos in git bash?

@alsongarbuja
Copy link

how to make file.md in a repos in git bash?

You can use the "touch" command to create any file inside git bash

touch file.md

@divycraft
Copy link

once i am in txt file how to get out of it?

@SiddharthM458
Copy link

SiddharthM458 commented Aug 13, 2023

How do we create a folder in Windows for that command we want to pass in git bash ?

@veereshnj
Copy link

This is for windows command

To create a folder : mkdir foldername(example - docs)
To create a file inside a folder : echo filename(example - index.html )

@Nfor-Becky
Copy link

they tell me it doesn't exist

@MallammaHR
Copy link

Can I use the touch command in windows prompt?
yes you

touch: cannot touch 'first.html': No such file or directory

I need solution

are you working in bit bash or command prompt??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment