GitHub: git status: showing staged > deletions for already-deleted files, want to commit replacmnts

This is a GitHub question, so please forgive me if I'm not supposed to ask about Git Hub here.. I have a pre-made GH online repo for a react project, called "BuyNow" and it has been connected to my local repo folder such that I'm able to push and pull from it, from in terminal. I've now finished the project and want to update the repo by pushing to it from terminal. Its been a while since I've pushed anything and now, when I run 'git status' I first see: Your branch and 'BuyNow/main' have diverged, and have 1 and 4 different commits each, respectively. (use "git pull" to merge the remote branch into yours) Changes not staged for commit: (use "git add/rm <file>..." to update what will be committed) (use "git restore <file>..." to discard changes in working directory) deleted: ../.gitignore deleted: ../app.js deleted: ../package-lock.json deleted: ../package.json In my current local folder, I have files by these names (see picture attmt) which I want to keep and not delete locally. Using a 'git pull' here now would result in these local files getting deleted, so I don't want to use that. These files also no longer exist in the online repo either (https://github.com/nnall/BuyNow), I've since gone in and deleted these files from there, thinking that would possibly get rid of this 'changes not staged' message, but it didn't. How can I deal with these 'changes' it's asking me to commit? Again, just 'committing' would mean deleting the local files, so I don't want to do that. What do I do here? My repo: https://github.com/nnall/BuyNow
GitHub
GitHub - nnall/BuyNow
Contribute to nnall/BuyNow development by creating an account on GitHub.
No description
6 Replies
dys 🐙
dys 🐙16mo ago
Using a 'git pull' here now would result in these local files getting deleted, so I don't want to use that.
If you and upstream both changed the same lines in the same file, you'll get merge conflicts when you pull. If you changed different sections git'll merge them. I'm pretty sure that if you want to only overwrite those files with your versions you can do something like git log to find the commit id of your last version & then git checkout <commit id> filename.ext to make it that version.
thethingisback
thethingisbackOP16mo ago
"If you and upstream both changed the same lines in the same file, you'll get merge conflicts when you pull. If you changed different sections git'll merge them." Can you say again/explain what you mean to say here?
dys 🐙
dys 🐙16mo ago
You changed some lines in the file. Whoever pushed to your repo also changed some lines in that file. If you changed the same line in different ways you'll get a message from git there are merge conflicts you have to manually reconcile before the pull can complete. If you changed a line & the other person didn't change that line, the merged version will have your changes. The same for lines they changed that you didn't.
thethingisback
thethingisbackOP16mo ago
what happened was I first created the github repo. Then, in my project folder, before I created the react app, I connected my local folder to github such that I could push to github.... THEN, from this folder location I created the react app. And when react creates an app, it puts an otherwise empty parent folder around it.. So now, instead of the already-created and github-connected folder having all of the project files and being the root folder, react has put instead another folder there.. So then Github is only connected to an otherwise empty folder, that has inside of it, the actual project folder.
dys 🐙
dys 🐙16mo ago
mv project/* project/.* ./ will move all the files down a level in the tree. (Hidden files begin with a dot and are ignored by \*, so they need to be matched separately.)
thethingisback
thethingisbackOP16mo ago
good to know. I'm copying that down thank you
Want results from more Discord servers?
Add your server