Home > Enterprise >  Git Bash - Git is showing branches as being up to date when they actually aren't
Git Bash - Git is showing branches as being up to date when they actually aren't

Time:12-07

I've got two local branches, main and dev. When I try commiting and pushing changes from dev to main, it says everything is up to date and nothing actually happens. Additionally, my github repo does not reflect the latest changes in my local repo, even though I have tried pushing it up and it says it was successful. Commits are not showing on my new repo.

When I type "git remote show origin", this is the output:

$ git remote show origin
* remote origin
  Fetch URL: <myRepo'sURL>
  Push  URL: <myRepo'sURL>
  HEAD branch: main
  Remote branches:
    dev  tracked
    main tracked
  Local branch configured for 'git pull':
    main merges with remote main
  Local refs configured for 'git push':
    dev  pushes to dev  (fast-forwardable)
    main pushes to main (up to date)

I'm very new to git so sort of learning as I go. Anybody have any idea as to why I am experiencing this issue? I can run other commands to provide more info if needed

To push changes, here is the process I follow:

First, git status. The output is this:

On branch dev
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   __pycache__/app.cpython-39.pyc
        modified:   app.py

no changes added to commit (use "git add" and/or "git commit -a")

Then, I run "git add ." No output from this command.

Next, "git commit -m "test". Here is the output:

$ git commit -m "test"
[dev 5af52ce] test
 2 files changed, 4 insertions( ), 8 deletions(-)

Finally, "git push origin main". Here is the output:

$ git push origin dev
Enumerating objects: 20, done.
Counting objects: 100% (20/20), done.
Delta compression using up to 16 threads
Compressing objects: 100% (14/14), done.
Writing objects: 100% (16/16), 1.77 KiB | 1.77 MiB/s, done.
Total 16 (delta 10), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (10/10), completed with 3 local objects.
To <myRepo'sURL>
   0f1504d..5af52ce  dev -> dev

Thanks!

CodePudding user response:

When I try commiting and pushing changes from dev to main,

What you are doing is pushing from dev to origin/dev.
And since the remote repository display the default branch main, you don't "see" any obvious changes (you would need to switch to the dev branch in the web page in order to see your commit).

You can merge dev locally to main, then push main:

git switch main
git merge dev
git push
  • Related