This is my error when I use git add .
Please tell me how to fix that
It would be very helpful to post the actual message: screenshots tend to be extremely difficult to read
The error seems to indicate you’re using git submodules? If that is correct, I assume you have a really really good reason for using them, but would need a lot more info about what you’re doing than just one error message to be able to provide much help here.
And this is the file structure
I just only post one image at the same time. I post again, can you checkout please?
No, I mean copy-paste the text, not tiny pictures of text.
Are you using git submodules?
Or do you have git repos nested in git repos? ie have you initialised a repo in the frontend
folder and in the backend
folder and you’re now tring to push from the root folder?
You have a single project with two folders in. There’s nothing special about this, but if you want to track it all using git, then you initialise git in the folder that contains all the code, not just in a subfolder that contains a bit of the code
git add --all
then your changes are stagged and ready for commit
It’s still not working
So how can I do that? Can you show me please.
And the text error: “Changes not staged for commit:
(use “git add …” to update what will be committed)
(use “git restore …” to discard changes in working directory)
(commit or discard the untracked or modified content in submodules)
modified: frontend (modified content, untracked content)”
write the command in console
I can’t tell from one single screenshot of a file explorer what you’ve done, you have to tell me.
What exactly are you trying to do?
How do you think this should work?
What folder are you in when you running the command?
git puts everything in a folder called .git
in the project. Where is it? Is there a .git
folder in both of those subfolders?
Edit, sorry @ReaZ, didn’t mean to reply to your post, @nguyenducanhvt012 the above are questions for you
git add --all
if it doesnt work then, try
git reset
git add --all
then commit your changes
I don’t think this will work properly because afaics OP has either managed to set up git submodules, or they are trying to push from a root directory that contains subfolders that are also git repos (which is, practically, going to be the same as explicitly using git submodules).
I’m running in the folder contain both frontend
and backend
folder.I want to add two folders using git add .
, commit, push to Github. But the frontend uses create-react-app
and I don’t know if it has the error because of that or not . Backend folder was added normally
Is it two different repos? You can’t push them to the same place. With the frontend folder with the react app, did you git init
there and do the same in the backend folder.
It makes no difference what files or folders you have in a project. For that project, git just tracks everything in the folder it’s initialised in
Did you git init
only in the root folder, the one that contains both of them?
Where is the .git
folder (or folders)? It’s literally just a folder (or folders in this case) with some text files in, it (or they) will be located in one or more of the root folder, frontend folder and backend folder
the ‘M’ next to frontend folder is cleary saying that your file was Modifited, also the error confirm it that there are changes but these changes are not stagged.
Just use git add --all then git commit -m"commit_message" and then push it.
The commands need to be used in terminal and terminal working directory, (you can see working directory by writing pwd in console) have to be at the repo which you want to save, cd ~/react-blog-app. My advice is that you shouldnt go throught new things when you struggling with basics of basics.
yes it is modified, but if that subfolder is also being tracked by git, as in it has a .git
folder of its own, and then OP is trying to push from the parent folder, that will not work. Git thinks the OP is using git submodules (afaics they essentially are, albeit accidentally), and in that case git will just refuse to push until the submodule is committed, pushed and the repo is updated to reflect that.
The OP afaics definitely does not want this behaviour, but nevertheless it will prevent them doing what you’re suggesting here: this needs to be fixed before they can do the normal add/commit/push. But to fix it, need OP to give a few answers to untangle things
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.