질문
나는 로컬 및 원격으로 분기를 삭제하고 싶습니다.
Failed Attempts to Delete a Remote Branch
$ git branch -d remotes/origin/bugfix
error: branch 'remotes/origin/bugfix' not found.
$ git branch -d origin/bugfix
error: branch 'origin/bugfix' not found.
$ git branch -rd origin/bugfix
Deleted remote branch origin/bugfix (was 2a14ef7).
$ git push
Everything up-to-date
$ git pull
From github.com:gituser/gitproject
* [new branch] bugfix -> origin/bugfix
Already up-to-date.
Remote / Origin / Bugfix 지점을 로컬 및 원격으로 성공적으로 삭제하려면 어떻게해야합니까?
답변
요약 요약
$ git push -d <remote_name> <branchname>
$ git branch -d <branchname>
참고 : 대부분의 경우
로컬 지점을 삭제하십시오
로컬 지점을 삭제하려면 다음 중 하나를 사용하십시오.
$ git branch -d <branch_name>
$ git branch -D <branch_name>
- The
-d
option is an alias for--delete
, which only deletes the branch if it has already been fully merged in its upstream branch. - The
-D
option is an alias for--delete --force
, which deletes the branch "irrespective of its merged status." [Source:man git-branch
] - As of Git v2.3,
git branch -d
(delete) learned to honor the-f
(force) flag. - You will receive an error if you try to delete the currently selected branch.
원격 분기를 삭제하십시오
Git v1.7.0의 현재 원격 분기를 사용하여 삭제할 수 있습니다.
$ git push <remote_name> --delete <branch_name>
기억하기가 더 쉬울 수 있습니다
$ git push <remote_name> :<branch_name>
원격 분기 또는 태그를 삭제하려면 Git v1.5.0 "에 추가되었습니다."
Git V2.8.0부터 -delete의 별칭으로 git 푸시를 -delete에 사용할 수 있습니다.따라서 설치 한 Git 버전은 쉽고 어려운 구문을 사용해야하는지 여부를 결정합니다.
원격 지점 삭제 [5-JAN-2010 원래 답변]
Scott Chacon의 Pro Git의 3 장에서 :
Deleting Remote Branches
Suppose you’re done with a remote branch — say, you and your collaborators are finished with a feature and have merged it into your remote’s main branch (or whatever branch your stable code-line is in). You can delete a remote branch using the rather obtuse syntax
git push [remotename] :[branch]
. If you want to delete your server-fix branch from the server, you run the following:
$ git push origin :serverfix
To git@github.com:schacon/simplegit.git
- [deleted] serverfix
Boom. No more branches on your server. You may want to dog-ear this page, because you’ll need that command, and you’ll likely forget the syntax. A way to remember this command is by recalling the
git push [remotename] [localbranch]:[remotebranch]
syntax that we went over a bit earlier. If you leave off the[localbranch]
portion, then you’re basically saying, “Take nothing on my side and make it be[remotebranch]
.”
나는 Git Push Origin을 발표했습니다 : Bugfix는 아름답게 작동했습니다.Scott Chacon이 옳았습니다. 나는 그 페이지 (또는 스택 오버 플로우에서 이것을 대답하여 사실상 개 귀)를 원할 것입니다.
그런 다음 다른 컴퓨터 에서이 작업을 수행해야합니다
# Fetch changes from all remotes and locally delete
# remote deleted branches/tags etc
# --prune will do the job :-;
git fetch --all --prune
변경 사항을 전파합니다.
출처:
https://stackoverflow.com/questions/2003505/how-do-i-delete-a-git-branch-locally-and-remotely
최근댓글