Reputation: 1774
I'm new to the "git" system. I may have made a mistake and integrated all my local files into the "git" system.
I use "vs code editor" and discard all changes when I say gives me the following error: Git: fatal: You are on a branch yet to be born
.
this is what it looks like when I use the "git status" command in the terminal:
warning: could not open directory '.Trash/': Operation not permitted
On branch master
No commits yet
Untracked files:
(use "git add <file>..."
to include in what will be committed)
.. / .npm /
.. / .viminfo
.. / .vscode /
.. / .zsh_history
.. / Applications /
. /
.. / Documents /
.. / Downloads /
.. / Library /
.. / Movies /
.. / Music /
.. / Pictures /
.. / Public /
nothing added to commit but untracked files present(use "git add"
to track)
Please don't think I came here looking for a solution. I tried pretty hard. I even read the articles here carefully.How to remove local (untracked) files from the current Git working tree.
git clean
, git reset
commands, such as I tried but failed. I'm trying to find out what I'm missing. I don't want to use the wrong command and ruin everything. If you can explain while you're helping, I'll know and I'll be happy. Thank you.
Upvotes: 4
Views: 2460
Reputation: 535169
When you say git init
, you are doing two things:
You create a (normally invisible) .git folder in the current directory.
You place the current directory and all its subdirectories recursively under git control.
So, if you whip out the Terminal and say
% git init
...the current directory is your home folder, and that is where the .git folder is created, and now your home folder and all its contents at any depth have been placed under git control. Which is a really bad idea, putting your whole world under git control.
Okay, so then you say
% cd Desktop
% git status
Well, the Desktop folder is inside the home folder, and the home folder has the .git folder, so the Desktop folder is under git control, and the git status
command works, and correctly reports, "Hey, I'm supposed to be controlling all these files and folders. What would you like me to do?"
What you'd like it to do is nothing. You've made a silly mistake and you need to back it out. To do that, just delete the invisible .git folder you created earlier by mistake in your home directory. Done. Your world is no longer under git control.
(The easiest way to do that, in a modern Mac system, is to press Command-Shift-Period, which makes invisible folders visible, so you can see the .git folder and drag it into the trash.)
Now, if you also said git clean
while your world was under git control, you may have deleted some of your stuff. And when I say deleted, I mean deleted. That stuff is absolutely irrevocably gone. If you use Time Machine or Carbon Copy Cloner or similar, you might have a backup elsewhere, but that has nothing to do with git. You told git to delete things and it obeyed.
Upvotes: 7