2

**edited

I'm trying to commit a file to my repo after making some changes- I initially uploaded the files to the repo directly through github.

C:\Users\me\repos\grow-my-day>git add popup.js

C:\Users\me\repos\grow-my-day>git status
On branch main
Your branch is up to date with 'origin/main'.

nothing to commit, working tree clean

C:\Users\me\repos\grow-my-day>git commit -m "Edit popup.js"
On branch main
Your branch is up to date with 'origin/main'.

nothing to commit, working tree clean

C:\Users\me\repos\grow-my-day>git push
Everything up-to-date

when I run git log I see that it's saying the last change was made on July 3rd which was the initial commit.

Lulu
  • 45
  • 6
  • It's acting as if `popup.js` didn't change. – jthill Jul 11 '22 at 18:43
  • @jthill yeah, I figured. I still want to add the updated file to my repo though and I'm not sure what else to do – Lulu Jul 11 '22 at 18:47
  • That's the thing: Git's telling you it hasn't changed, it's not updated. – jthill Jul 11 '22 at 18:54
  • @jthill is there any way to override that? I changed the files after I uploaded them directly through github and created a clone on my local machine after the fact so that's probably the reason I'm having this issue – Lulu Jul 11 '22 at 19:00
  • Try `git add -f popup.js`. Newer Git versions tell you when `git add` bypasses an explicitly-added ignored file, as I recall it used to just, you know, ignore them. It's really not clear what you're doing here, what's going on, also try `git diff @ -- popup.js`. – jthill Jul 11 '22 at 19:25

1 Answers1

1

For both messages, a git status would be helpful:

So:

git push -u origin main

Note that with the recent (Q3 2022) Git 2.37, and its new git config --global push.autoSetupRemote true, a simple git push would be enough.

But with the status Your branch is up to date with 'origin/main'., there is nothing to push anyway.

If the file is not present at all on the remote side, check if it is ignored locally.

git check-ignore -v -- popup.js
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • yeah you're right my current branch was main.. I got confused looking at other stackoverflow answers to similar questions. ``git push -u origin main`` works but the file is not updated on git – Lulu Jul 11 '22 at 18:59
  • @Lulu I have edited the answer to suggest checking if your file is ignored locally. – VonC Jul 11 '22 at 19:00
  • hmm, I get no output when I check if the file is being ignored – Lulu Jul 11 '22 at 19:20
  • @Lulu So it is *not* ignored. Do you see it on the GitHub side? With its content up-to-date? – VonC Jul 11 '22 at 19:30
  • yeah it's on my github because the initial commit was through upload on the github website, but the content is not up to date. I think uploading the files through github directly and then creating a clone of the repo after the fact may be creating the issue – Lulu Jul 11 '22 at 19:44