Search code examples
gitgit-branchbranching-and-merginggit-remote

Replace one local branch with another local branch... and preserving tracking


I have 2 local branches that are tracking different repositories:

  • local-live ( tracks our live repo )
  • local-staging ( tracks a staging repo )

We have "continous deployment" set up so when I push my local-staging up staging environment will be updated with the changes. I want staging to reflect the code that's on live( which isn't the case currenly).

How might I replace my "local-staging" branch with code from my "local-live" branch? I want to wipe all staging changes making staging reflect what's on live. I want my local-staging to still be tracking the staging repo( ie "git push" from staging will act as expected )

Hope this is clear. Thanks.


Solution

  • you want to do a hard reset.

    git checkout local-staging
    git reset --hard local-live