Git - How to recover a deleted remote branch

git branch -D <DELETED_BRANCH_NAME> git checkout -b <DELETED_BRANCH_NAME> <COMMIT_ID> git push --set-upstream origin <DELETED_BRANCH_NAME>
If you deleted the remote branch by accident you want to recover it with the most recent changes. In order to do so you delete the local branch and create it afterwards with the current commit id. Afterwards just push the new reference to origin.

Precedent error: Your configuration specifies to merge with the ref 'refs/heads/<DELETED_BRANCH_NAME>' from the remote, but no such ref was fetched.

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.