Infinite loop of "please commit your changes" for package.json & .package-lock.json
I'm working off of a developer branch, 'jordan', right now. I've done everything I have to do there, committed and pushed my changes to that 'jordan' branch, refreshed the GH page in the browser and see my 'jordan' push having occurred.
'main' is a different branch and has changes to it that are not reflected in my 'jordan' branch
I want to continue working in my 'jordan' branch, but I would like to first merge the 'main' branch changes into 'jordan'.
I've tried
git pull origin main
but it tells me that I'm already up to date.
I then try to simply checkout to main
, and I'm given a message saying there are changes to my package.json
, package-lock.json
files I need to commit before I can checkout.
I haven't made any changes to these files, and have re-added, committed everything multiple times, even getting the message "your branch is up to date with origin/jordan', but as soon as I try to checkout, I get the changes not staged for commit:
message RE package.json, etc.
What could be causing this, how do I proceed?5 Replies
git add .
only adds files in the current directory, your changes are in the parent dir (..
)
so go up one level (cd ..
) then run git add .
and git commit -m "whatever you want"
cd ..
oops okay, trying that now
you have no idea how often I've run shell commands in chat applications 🤣
lol
It worked, I committed those files finally and I can navigate between branches again.
My question though, for getting those changes from 'main' into my jordan branch.
Is this correct:
checkout 'main' (locally)
perform git pull :
git pull origin main
<-- to update my local 'main' branch
navigate back to 'jordan' branch : git checkout jordan
And then finally merge my local 'main' branch into my local 'jordan' branch : git merge main
Is this right?
I want to push to a git branch, but there has been a file pushed to the remote branch which my push doesn't have, so I'll need to do a git pull from that remote branch first.
My local branch have several other changes that I don't want to be overwritten by the remote branch's 'git pull'.
I'm assuming I can choose to keep my local branch copies where there are differences, right? How would I prevent my local branch files from being overwritten by the git pull?
Again, this is all just so that I can finally do a 'git push' of my locally-saved work, to the remote branchthat would update your jordan branch based on the changes made on the main branch
you always pull before you push. Changes should be merged instead of overwritten. You can always make a local copy of your entire repo if you aren't sure what'll happen
though don't push if the result isn't what you wanted