Create new file from terminal git
To create a new file from the terminal using Git, you can use the following commands:
-
Create a new file:
touch filename.txt
This will create a new file called
filename.txt
in the current directory. -
Add the file to the Git index:
git add filename.txt
This will stage the new file for the next commit.
-
Commit the changes:
git commit -m "Initial commit"
This will commit the changes with a message "Initial commit".
-
Verify the changes:
git status
This will show you the status of your repository, including the new file.
-
Push the changes to the remote repository:
git push origin master
This will push the changes to the remote repository.
Note: Replace filename.txt
with the actual name of the file you want to create. Also, replace origin
and master
with the actual name of your remote repository and branch, respectively.
Alternatively, you can use the following command to create a new file and add it to the Git index in one step:
git touch filename.txt
This will create a new file and stage it for the next commit.