2

enter image description here

I've made some commits but I can not see them for the push.

I've read this may be related to not having a remote? But here is the result of the command line:

$ git remote
origin 

UPDATE:

git status command result:

git status
HEAD detached from 5235085
Untracked files:
  (use "git add <file>..." to include in what will be committed)

    .idea/
    Connect4Py/__pycache__/

nothing added to commit but untracked files present (use "git add" to track)

git branch -avv command result:

git branch -avv
* (HEAD detached from 5235085) 908eb97 Fix: - New camera OpenCV configurations      - Improved the Yellow and Red Ball detections.      - Improved the Matrix placement of the balls.
  main                         6dc0b73 [origin/main] Fix: bug fixes
  temp                         1e084c0 Fix: - New camera OpenCV configurations      - Improved the Yellow and Red Ball detections.      - Improved the Matrix placement of the balls.
  remotes/origin/HEAD          -> origin/main
  remotes/origin/main          6dc0b73 Fix: bug fixes

Note: The fix: bug fixes commit was not made by me, that was another user and his commit-push commands were successful.

noobie
  • 361
  • 2
  • 9

1 Answers1

3

Still in command-line, check the output if git status

If you are in detached HEAD mode (not in a branch), check your local and remote branches (git branch -avv), and see which one you should be on.
You can then switch to the right branch, and merge your detached HEAD.

git switch -c tmp
git switch main
git merge tmp
git branch -d tmp

For older Git:

git checkout -b tmp
git checkout main
git merge tmp
git branch -d tmp

From there, you will be able to push, including from PyCharm.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Sorry, I am really new to these stuff. I updated my question, can you please explain what to do from there step by step? – noobie Dec 01 '21 at 08:05
  • @noobie No problem. I have edited the answer accordingly. – VonC Dec 01 '21 at 08:07
  • I get git: 'switch' is not a git command. error. I checked and updated the git: git is already the newest version (1:2.17.1-1ubuntu0.9) but still can not use the switch command. I've looked this solution: https://stackoverflow.com/questions/47630950/how-can-i-switch-to-another-branch-in-git but I am too afraid to use the commands since the project is really big and there are other contributers – noobie Dec 01 '21 at 08:13
  • @noobie 2.17? I wasn't born yet. Can you try and upgrade to 2.34.1? https://stackoverflow.com/a/41357503/6309 – VonC Dec 01 '21 at 08:32
  • @noobie If no upgrade possible, I have edited the answer with the old commands for older Git. – VonC Dec 01 '21 at 08:33