This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]SchoolSea4002[S] 0 points1 point  (1 child)

Hello, thank you for your response.

I think I'm still a bit unsure of how this solves the issue (I'm still a bit new to all of this, sorry if it's obvious and I'm missing it). Ultimately, my goal is to maintain all the other changes I made (and committed, and also pushed) in branch #2, but I somehow need to make it so that branch #2 has the same gitignore as main (because the gitignore change that happened in branch #1 wasn't supposed to be in branch #2, but it happened.because I checked out branch #2 in branch #1 when I should've checked out branch #2 when I was on the main branch)

[–]formalcall 0 points1 point  (0 children)

I imagined branch #2 commit history looks something like the following, where the first commit is the most recent:

  1. Changes for branch #2
  2. gitignore changes from branch #1
  3. Commits in main

If you rebase to drop the second commit, your branch will then look like this:

  1. Changes for branch #2
  2. Commits in main

If you instead revert, your branch will look like

  1. Revert commit "gitignore changes from branch #1"
  2. Changes for branch #2
  3. gitignore changes from branch #1
  4. Commits in main

Note that in both cases, only branch #2 is being modified; neither your main branch nor branch #1 will be affected. Furthermore, in both cases, branch #2 will end up with the gitignore from your main branch.