Saturday, February 2, 2019

How to create an empty git branch


Sometimes we may want to create a different project (storing some documentation or some other files)inside our available repository. We can achieve this by creating a new branch by using normal "git checkout <branch-name>" command. But the correct way is

git checkout --orphan <branchname>


so that a new branch will be created inside the repo and automatically switched to the same. The new branch doesn't have a parent branch. We may need to execute the below commands to clear the cache and leftover files.

git rm --cached -r
git reset --hard


Once you created the orphan branch and after adding your new files, commit and push it. So that the branch will be available to all team members.

No comments:

Post a Comment