0

I was working in my repository on branch_old but then wanted to create a new branch, lets say branch_new, for my local changes and finally push this new branch onto remote, so I ran

git checkout -b branch_new

git add .

git commit -m "Some message"

git push -u origin branch_old

while I meant to ultimately run git push -u origin branch_new.

As a return, I got

Everything up to date

branch 'branch_old' set up to track 'origin/branch_old'

Now I'm quite new to git and I don't really know if that messed something up with the setup of my original branch branch_old. I couldn`t find a post with the same problem, so can someone tell me if that wrong push command was harmful and if yes, how can I fix this issue?

Thanks in advance.

Infty
  • 13
  • 4
  • You did nothing harmful here. You probably didn't want to push the old branch but you did - however, you can delete that branch (on the remote) if you like, and in any case it is nothing harmful in itself. – topsail Jan 24 '23 at 16:51

1 Answers1

0

The information of an "upstream" branch is only local information. This is not something that is pushed to the remote. You can find the information in .git/config inside your local repository, something like:

[branch "branch_old"]
    remote = origin
    merge = refs/heads/branch_old

To change the upstream, you can run

git branch branch_old --set-upstream-to origin/branch_new

A more detailed version of this answer for older git versions etc can be found here: How to change the remote a branch is tracking?

Chris Maes
  • 35,025
  • 12
  • 111
  • 136