4

I want to delete the local and remote feature branch. After deleted the local branch, I deleted the remote branch by right-click the branch under remote/origin/feature. The branch is disappeared on my local and remote branch (origin), but still exist in other user's sourcetree. How to solve this? Thanks!

ps: I want other users cant see the branch as well. I guess the reason is I pushed the feature to develop. How can I get back the branch to my remote branch origin in order to reverse commit first?

WILLIAM
  • 457
  • 5
  • 28
  • To the Stackoverflow admins: the question is with regards to how you do this in the SourceTree app, not how you do it on the command line in git. This question should be re-opened, I have an answer to provide. – Oliver Pearmain Dec 09 '21 at 09:48

2 Answers2

2

You can delete like this git push <remote_name> --delete <branch_name>

For example: git push origin --delete feature/test-branch

Where: - origin is name remote repository - feature/test-branch is name your branch that will be deleted

Rider_BY
  • 1,129
  • 1
  • 13
  • 31
  • Thanks! but I have already removed in my sourcetree. This error occur when I try your command in terminal. error: unable to delete 'feature/module': remote ref does not exist – WILLIAM Mar 24 '20 at 09:32
  • 1
    It seems like the branch is already deleted remotely. If others are still seeing the branch remotely, it's because they haven't done a `git fetch`, so they're looking at an outdated version of the remote. – vanamerongen Mar 24 '20 at 16:28
0

if I correctly understand your question, try using this in your terminal

git push <remote_name> --delete <branch_name>

Where is is branch you want to delete. For example:

git push origin --delete feature
PawMaw
  • 101
  • 1
  • 9
  • Thanks! but I have already removed in my sourcetree. This error occur when I try your command in terminal. error: unable to delete 'feature/module': remote ref does not exist – WILLIAM Mar 24 '20 at 09:32
  • maybe you should recreate your branch locally, then git push --set-upstream and then try again to delete? – PawMaw Mar 24 '20 at 11:14