Reputation: 1588
I checked out a branch for testing purposes(let's call it Test
) to see if it would be easy to do something. After seeing that it wasn't a good idea I just want to drop the branch. Can I just $ git checkout Development
and just forget all about Test
branch? Or would it be better to delete the branch? should I $ git reset head
?
Upvotes: 1
Views: 1585
Reputation: 171
Delete local branch:
`git branch -D <branch_name>`
Delete remote branch:
`git push <remote_name> --delete <branch_name>`
usually the <remote_name>
is origin
.
And yes, I think if the branch won't be used in the future it should be deleted, especially if it is pushed to the remote server. Because it grows the size of the repository even for developers that haven't checkout-ed this specific branch.
Upvotes: 1
Reputation: 38924
Change to your original branch and maybe clean up any remaining file that was ignored by version control. That's all. If you want to, you can also git branch -D Test
(capital D to avoid warnings about unmerged branch) but from experience, you should probably wait some time before doing so because you might want to go back to it a later point. I often cleanup local branch only after I am done implementing a feature.
Suppose you created Test
and now you go back to master
:
$ git checkout master
You may have untracked files in your directory:
$ git status
On branch master
Untracked files:
(use "git add <file>..." to include in what will be committed)
some_file
nothing added to commit but untracked files present (use "git add" to track)
You can simply delete the file manually, or run git clean:
$ git clean -n # -n says dry-run
Would remove some_file
The above just shows what would clean
do; to really do it, enter:
$ git clean -f
Removing some_file
All the above applies to a local clone of your repository. In case you need to delete a remote branch, you can either do it from the Web interface, or Delete the branch from command-line.
Upvotes: 1