Deleting a local git branch is easy, using options `-d` or `-D` will do it. Its is always safe to use `-d` option because it won’t allow us to delete unmerged branch, where as `-D` will delete the unmerged branch without any warning or notification.
git branch -d branch_name_to_delete
But this will delete only branch in our local system.
Delete remote branch
So how can we delete a remote branch? Any way none of the option for git branch won’t delete it. Remote branch can only deleted by using git push command.
git push origin :branch_name_to_delete
You have to notice the full-colon (:) prefixed to the branch name. The prefixed colon is the one asking git to do the trick.
While working on a project, I was unable to configure git on the shared host. It was a nightmare to upload only the changed files after a bug fix. Keeping track manually on all the changed files got failed. So I started searching for a easy solution and I end up with a script which I can copy the changed files between two commits with directory structure.
In this I only need to keep track of the last uploaded commit, which seems to be easy for me. You just need to save the below script to git-copy.sh file and keep in the root folder of the project. Don’t forget to give execute permission for the file.
How to Use
This script accepts three parameters.
The Hash of First commit
The Hash of second commit
The destination folder, where we need to copy the files.
Have you ever thought that it should be good if the git output in your terminal is colourful? ie.,
Added files in one colour
untracked files in some other colour
Added lines and deleted line is differentiated with colour
Here is the simplest way you can achieve it. Just run the following command after changing the directory into project directory/git repository
This will show the git output in colour, only for this specific git repository. If you need the same for all git repository then you should run
Now check your git output. It will be colourful and you will find really easy to differentiate the added and untracked files. Try git diff, you will find even more easier to find the added and deleted line.
Where Am I?
You are currently browsing entries tagged with git at