0

I'm working on a project, where I have 4 branches, but I'm focused on one branch at the moment. I'm not sure what happened but I've made changes to my code, and tried to commit and push, however Git is telling me that "Everything up-to-date" when clearly it's not as there are modified files that I've staged and tried to commit.

I've looked at these links Fix a detached head, git push says "everything up-to-date" even though i have local changes where I could possibly be in a detached HEAD however, to be completely honest, I'm not sure how to know this.

Here is the output of git branch -a and git status:

codio@senior-miranda:~/workspace$ git branch -a
  bug-remove-logged-msg-01
  home-page
  master
  selling-items
* styling
  stylingchanges
  remotes/origin/home-page
  remotes/origin/master
  remotes/origin/remove-loggedin-message
  remotes/origin/selling-items
  remotes/origin/styling
codio@senior-miranda:~/workspace$ git status
On branch styling
Your branch is up to date with 'origin/styling'.

Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

        modified:   views/register.handlebars

codio@senior-miranda:~/workspace$ git commit -m "viewport meta"
PRE-COMMIT
codio@senior-miranda:~/workspace$ git push
Everything up-to-date
Everything up-to-date

The PRE-COMMIT hook runs ESLint and if any errors arise, prevents the commit from happening. After checking, I can confirm the PRE-COMMIT exits with a value of 0.

Output of git log --oneline --graph -5:

codio@senior-miranda:~/workspace$ git log --oneline --graph -5
* a5198f5 (HEAD -> styling, origin/styling, origin/selling-items, stylingchanges, selling-items) added prefers colour scheme css
* fb44eec linter new line
* 5aa511f responsive cards on home
* 65d0765 (master) linter newline
* daedd13 working on theme changer + navbar improvements
banf
  • 65
  • 1
  • 6
  • Hi, please take the time to search and understand what information is displayed by git status. In your case : it says that changes are added, but not committed yet. You have to commit them before you can push them. – LeGEC Dec 09 '20 at 13:49
  • Hi @LeGEC view updated image. – banf Dec 09 '20 at 13:51
  • Also, as a general rule on SO : avoid pasting screen captures, paste text (especially when it is as easy as copy/pasting a terminal output) – LeGEC Dec 09 '20 at 13:55
  • Tell us about your pre-commit hooks. – matt Dec 09 '20 at 13:57
  • The pre-commit hook runs ESLint and if any errors come up exits with 1, but after checking now, I can see it exits with 0. – banf Dec 09 '20 at 14:02
  • Check your status and history before and after committing : `git status -s; git log --oneline --graph -5` – LeGEC Dec 09 '20 at 14:04
  • @LeGEC see updated post with output. – banf Dec 09 '20 at 14:07
  • Is this a new branch? Maybe you need to push the branch more explicitly. You are on three branches at once, which is quite weird; poor old Git may not know which one to push. – matt Dec 09 '20 at 14:31
  • @banf : as you can see, your `styling` branch is still on commit "added prefers coulour scheme css". So your issue is : the commit was not created. You have to debug why. Since you have at least one `pre-commit` hook installed : double check that it runs succesfully, also check if you have a `commit-msg` hook installed (those are the hooks that can [block a commit](https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks#_committing_workflow_hooks)) – LeGEC Dec 09 '20 at 15:57
  • If you bypass the hook, running `git commit --no-verify`, are you able to create your commit locally ? if yes : this means the pre-commit hook is the culprit. if no : the culprit is elsewhere. – LeGEC Dec 09 '20 at 15:58
  • I believe in the end the culprit was the hook ‍♂️ my apologies! Renaming the hook to `pre-commit.sample` allowed me to commit, which is really strange as the hook was working before and I haven't changed it. Anyway, thanks for the help! – banf Dec 09 '20 at 18:48
  • The hook itself probably has a bug in it. Good hooks are hard to write. :-) – torek Dec 09 '20 at 20:55

3 Answers3

1

The issue in the end I believe was the pre-commit hook, which is really strange as it's exiting with a value of 0, nevertheless thanks everyone for the help.

Renaming the hook back to a sample (pre-commit.sample) fixed my issue.

banf
  • 65
  • 1
  • 6
0

Did you add your files before? git add -A and then commit

Patricia
  • 2,885
  • 2
  • 26
  • 32
0

Have you checked your git status after committing ?

Have you checked your local history, (in a terminal : git log --oneline --graph, or an overview in any graphical frontend)
in particular what is your local branch state with respect to its remote counterpart ?


The output of your git commit command indicates that you have a pre-commit hook (one that at least prints PRE-COMMIT on your terminal), do you know what this hook does ?

If this hook exits with an error code, the commit will simply be rejected, and git does it silently (it relies on the hook printing explanations on why the commit was rejected).

LeGEC
  • 46,477
  • 5
  • 57
  • 104