Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如果我已经将Git分支合并到master,我可以删除该分支本身吗?_Git_Version Control - Fatal编程技术网

如果我已经将Git分支合并到master,我可以删除该分支本身吗?

如果我已经将Git分支合并到master,我可以删除该分支本身吗?,git,version-control,Git,Version Control,如果我有一个已合并到主分支中且不再需要作为单独分支的功能分支,我可以从本地回购和原始回购中删除功能分支吗?删除本地git分支: git branch -D <branch_name> git push origin --delete <branch_name> git分支-D 删除远程git分支: git branch -D <branch_name> git push origin --delete <branch_name> git推

如果我有一个已合并到主分支中且不再需要作为单独分支的功能分支,我可以从本地回购和原始回购中删除功能分支吗?

删除本地git分支:

git branch -D <branch_name>
git push origin --delete <branch_name>
git分支-D
删除远程git分支:

git branch -D <branch_name>
git push origin --delete <branch_name>
git推送原点--删除

如果问题是这是否会是一个问题:否,如果合并了所有提交

是的。可以删除单个要素分支:

# Delete a single branch that has already been completed locally and then remotely

$ git branch -D my-feature-branch
$ git push origin :my-feature-branch
或者,可以删除已合并到集成分支中的所有要素分支:

# The following command deletes all LOCAL branches that have been merged into the current commit, where the branch name starts with 'feature', except for branch 'integration'.
# You will need to remove the 'echo' to actually run it.

$ git branch --merged | grep -i feature | grep -v integration | xargs -i echo git branch -D {}

# The following command deletes all REMOTE branches that have been merged into the current commit, where the branch name starts with 'feature', except for branch 'integration'.
# You will need to remove the 'echo' to actually run it.

$ git branch -r --merged | grep -i feature | grep -v integration | cut -d '/' -f 2 | xargs -n 1 echo git push --delete origin

# The following command deletes all REMOTE branches that have been merged into master
# You will need to remove the 'echo' to actually run it.

$ git checkout master
$ git merge origin/master --ff-only
$ git branch -r --merged | grep -v master | cut -d '/' -f 2 | xargs -n 1 echo git push --delete origin

如果您认为已经合并了分支,那么使用
git branch-d
git branch--delete
删除分支是完全安全的,因为它们不会删除未合并的分支。如果分支没有合并分支,小写的
d
将导致git警告您,但是如果您想删除分支而不保留最近的提交,那么
git branch-d
将强制删除


要删除远程分支,请使用
git-push-origin:
,或
git-push-origin--delete

只要合并时分支历史记录没有丢失,就不应该出现问题git-push—它如何知道当前分支?这会删除当前的分支吗?因为我是新来的,我不知道它会解释html标记。。。即使它们是无效的。