[GIT]Cách chỉ đổi tên nhánh trên server trong git / How to just want to rename branches remotely?

Bạn có nhánh “bugfix_ticket1” trên server git origin. Một lý do nào đó cần đổi tên nhánh này thành “bugfix_ticket1_old” mà không làm ảnh hưởng gì đến local hiện tại của bạn.

Cách thực hiện syntax chung như sau, không quan tâm hiện tại đang đứng trên nhánh nào :  (Chú ý đến từng dấu cách, dấu chấm và dấu phẩy nhé!)

git push <remote> <remote>/<old_name>:refs/heads/<new_name> :<old_name>

Cụ thể giải quyết cho mô tả ban đầu đổi nhánh từ: bugfix_ticket1 => bugfix_ticket1_old

git push origin origin/bugfix_ticket1:refs/heads/bugfix_ticket1_old :bugfix_ticket1

 

If you really just want to rename branches remotely (without renaming any local branches at the same time) you can do this with a single command like

git push <remote> <remote>/<old_name>:refs/heads/<new_name> :<old_name>

To integrate @ksrb’s comment: What this basically does is two pushes in a single command, first git push <remote> <remote>/<old_name>:refs/heads/<new_name> to push a new remote branch based on the old remote tracking branch and then git push <remote> :<old_name> to delete the old remote branch.