-1

I accidentally committed and pushed my changes and also node_modules into a remote branch.

So, to fix, I tried rebase by doing: (Don't mind if I didn't include in the steps adding node_modules into gitignore since I did it in separate process)

  1. git log
  2. git reset "to the commit that includes the node_modules"
  3. git add "only the files that needed to be committed and pushed"
  4. git status (node_modules are now unstaged)
  5. git commit -m "remove node_modules"
  6. git push -f

Now its working as expected (to commit and push my changes), if I pull request, it says no conflict with master.

But I'm curious as to how merge works, does it also merge the commit which includes node_modules, or will it just merge the latest commit ?

Because my goal is to only merge to master the newest commit that excludes the node_modules and ignore the commit that includes the node_modules

jthinam
  • 279
  • 2
  • 7
  • See also [How does 'git merge' work in details?](https://stackoverflow.com/q/14961255/1256452) (not exactly a duplicate; there are duplicates but I was not able to find one quickly) – torek Mar 30 '22 at 20:56

1 Answers1

0

You can check the difference between your branch and master for example with:

git fetch origin
git log --oneline origin/master..<your_branch>

This will show the commits that are present in your local branch and are not present in origin/master

VANAN
  • 488
  • 2
  • 5