A branch on our cloud repository was deleted. I still have this branch in my local git repository. I want to restore this branch in the cloud repository.
Is this possible?
A branch on our cloud repository was deleted. I still have this branch in my local git repository. I want to restore this branch in the cloud repository.
Is this possible?
Below command directly changes the remote branch you mentioned
git push -f origin <previous_commit>:<branch_name>
Locally try below command
git reset --hard <previous_commit>
And now push the changes to remote
If I push the unmerged branch from my repo, will it reappear in the cloud repo as a merged branch? Or will it reappear as a separate branch?
As a separate branch.
But the remote repository already has those commits (that you are pushing) through its merge commit: a merge commit has two parent, the second one being the branch being merged.
All you will be pushing will be the branch name on the last commit of that branch.
Deleting a branch after it has been merged is correct behavior. You should not push and undo all of that. You should fetch and prune, and delete your local copy of the branch.