Question

So I've been trying to create a text file using Git, I punched in the command "touch home.html", then I punched in the command git "add home.html", then I input "git status" and the file doesn't want to appear, I have relaunched the finder multiple times, nothing.

enter image description here

enter image description here

Was it helpful?

Solution

You're running git status in the wrong repository (your home directory, ~, i.e. /Users/adam). You need to move into the repo that you want to act on, i.e. cd ~/Desktop/Tools/Git/MyFolder, or a subdirectory of this, and then run git status.

You've created the home.html file in ~.

You must have run git init on your home directory or a parent of it, i.e. /Users/adam, /Users, or /. The first is most likely, as the others would require use of sudo. You can forget about / get rid of this repo by running rm -rf .git within that directory.


I encourage you to learn the basics of Git by watching this video.

Here's a good video on Linux terminal basics as well. macOS isn't Linux, but it's Unix-based, just like Linux, so the principles are the same; the knowledge directly applies to macOS.

OTHER TIPS

Why not use text edit to save a text file in that finder window.

Remember, Finder hides all files and folders with a . by default but you have an easy key shortcut to toggle that.

My thinking is you have nothing amiss in the graphical side, but you’ll want to troubleshoot a little using purely command line tools or purely graphical tools to avoid mixing idioms and troubleshooting steps.

For the next edit of your question, be sure to state where you are working. A folder on your desktop is ideal to avoid permissions errors if your git is elsewhere.

The files to be tracked and .git folder need to be in one folder.

Myfolder
 |- .git
 |- home.html

Use cd to navigate. Use man cd in case there is a doubt.

Examples:

>>> pwd
~/Desktop
>>> cd Tools/Git
>>> pwd
~/Desktop/Tools/Git
>>> cd Myfolder
>>> pwd
~/Desktop/Tools/Git/Myfolder

Now use touch to make the HTML file and see if git can see it, and add it to tracking.

http://git.github.io/git-reference/basic/

File Management

then I input "git status" and the file doesn't want to appear,

Use > operator to send the output of any command in Terminal to a txt or log file.

This command creates an empty text file named abc on Desktop.

touch ~/Desktop/abc.txt

This command sends the output of git status to a file status.txt, you can change the location and filename.

>>> git status > ~/Desktop/status.txt

This command opens any txt/rtf/log file at the given path with TextEdit.app.

>>> open -a /Applications/TextEdit.app ~/Desktop/status.txt

https://linuxhandbook.com/create-file-linux/

Licensed under: CC-BY-SA with attribution
Not affiliated with apple.stackexchange
scroll top