1

i have a simple question, if i have a branch called a then i checked out another branch from that one, called b, i made some changes in b, commited, then pushed it, and merged b back into a.

now a gets the changes locally on my machine but not in the github website, and a doesn't consider the changes that i've merged as a change in branch a so i can't manually commit then push to a so that it reflects on the github site. how to solve that ?

i tried to change the merged file then push manually, but why would i need to change the file after the merge if i already made all the changes before merging.

  • did you not push after the merge? – perivesta Dec 01 '22 at 06:55
  • i didn't push into branch `a` but i would do it if i can, that's the problem after i merge `b` into `a`, `a` has no changes to commit and push so i have to make further unnecessary edits in it if i want to push. – EpsilonCode Dec 01 '22 at 07:00
  • `a` has no changes to commit but it still has new commits that haven't been pushed yet (the ones you merged). `git status` should say something like *ahead of 'origin/a' by X commits.* – perivesta Dec 01 '22 at 07:02
  • after i merge `b` into `a`, running `git status` in `a` gives (nothing to commit, working tree clean) – EpsilonCode Dec 01 '22 at 07:06

1 Answers1

1

and merged b back into a.

If you merged it online through PR (Pull Request), then you would need to refresh a locally.

If you merge it locally, then it depends on how b was merge to a, especially if "a has no changes to commit and push".

git switch a
git merge b
git push
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • i merge locally, and `a` doesn't have changes to commit before i merge `b`, then after i merge `b` into `a`, that doesn't change it's still (nothing to commit, working tree clean) when running git status in `a` (although i made changes in `b` before merging it back to `a`) – EpsilonCode Dec 01 '22 at 07:11
  • @EpsilonCode Do you see commits in b, compared to a, when you do a `git log --oneline --graph --all --branches --decorate`? – VonC Dec 01 '22 at 07:16
  • oh, yes i see the commits, thanks, now i understand, it says (nothing to commit) not because it didn't consider it as a change that i have to commit but because it commits it, all i had to do was to push. but it's a bit unclear for git to say (nothing to commit) after i merge changes into the branch (I'm just used to committing then pushing not git committing for me), however thanks for your help. – EpsilonCode Dec 01 '22 at 07:28
  • @EpsilonCode Yes, `git merge` is purely local. – VonC Dec 01 '22 at 07:29