0

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

anki
  • 11,753
  • Excellent edit. Shift command . will make files and folders with a . visible. – bmike Jan 24 '20 at 18:51
  • In Catalina I've frequently had newly created files not appear in the Finder. Even Safari downloads & new Pages or Numbers documents. If the creating application has a Show in Finder action (as Safari does) that will reveal it. Otherwise relaunching the Finder (which is a pain) makes them visible for me. – Pedro Jan 25 '20 at 04:52

3 Answers3

1

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.

Jivan Pal
  • 1,215
  • 10
  • 20
0

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.

bmike
  • 235,889
0

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/

anki
  • 11,753
  • Visibility of hidden files is the issue here unless I’m missing something. – bmike Jan 24 '20 at 18:52
  • They made the html file in ~/ (see the bash prompt in Terminal) and the git setup is three folders deep. (see finder screenshot) – anki Jan 24 '20 at 18:52
  • 1
    right now, there are two gits, one in ~/ and another in ~/Desktop/Tools/Git/Myfolder – anki Jan 24 '20 at 18:56
  • okay maybe they want git status 's output to go to a txt file, instead of Terminal. – anki Jan 24 '20 at 18:59
  • I want the txt file to appear, I just did the git status > ~/Desktop/status.txt, still nothing appears – Adam Ciwinski Jan 24 '20 at 19:05
  • @AdamCiwinski Run open ~/Desktop/status.txt – anki Jan 24 '20 at 19:09
  • open ~/Desktop/status.txt, it worked and it opened in the terminal. – Adam Ciwinski Jan 24 '20 at 19:12
  • so, in short, I should do the following, open ~/Desktop/Tools/Git/MyFolder/example.txt – Adam Ciwinski Jan 24 '20 at 19:19
  • @AdamCiwinski What is example.txt ? – anki Jan 24 '20 at 19:20
  • just a file to create – Adam Ciwinski Jan 24 '20 at 19:20
  • @AdamCiwinski https://linuxhandbook.com/create-file-linux/ – anki Jan 24 '20 at 19:22
  • To summarise quickly, we can't get it to open on the folder only on the desktop? , and the file name has to be status.txt? – Adam Ciwinski Jan 24 '20 at 19:23
  • RE: "This command creates an empty text file on Desktop. echo > ~/Desktop/abc.txt" ... No it does not create an empty file, however, and assuming the target doesn't already exist, touch ~/Desktop/abc.txt creates an empty file, 0 bytes. The echo > ~/Desktop/abc.txt command creates a 1 byte file with a line feed character (0A). It also overwrites an existing file of the same name if it already exists. – user3439894 Jan 24 '20 at 19:34
  • @user3439894 as if the question displayed enough knowledge (and clarity) of such intricacies. I chose to give the simplest method. – anki Jan 24 '20 at 19:35
  • @user3439894 Thanks for correcting me though, learnt something new today. – anki Jan 24 '20 at 19:38
  • Doesn't matter what intricacies the OP shows, although it did state that "touch home.html" was used to create the file. What matters is you're making a statement that is not factually true! – user3439894 Jan 24 '20 at 19:41