How to push new branch without history

In this article you see that how you can easily push a branch without history 


To push a new branch without history, you can use the --orphan flag with the git checkout command to create a new branch with no parent history, and then push it to the remote repository with the git push command.

 

Purging all the files does not remove the commit history. To create a new branch with no history, you can use the --orphan option with the git checkout command. Here are the steps:

 

Here are the steps to create a new branch without history:

 

1. Switch to the branch that you want to base your new branch on, usually the master branch:

 

git checkout master

 

2. Create a new branch with the --orphan flag:

 

git checkout --orphan new_branch

 

3. Commit your changes to create the initial commit of the new branch:

 

git commit -m "Initial commit"

 

4.  Push the new branch to the remote repository with the -u flag to set the upstream branch:

 

git push -u origin new_branch

 

This will create a new branch named new_branch with no history and push it to the remote repository. Note that any subsequent commits to this new branch will have no relationship with the parent branch history.


Tags:

git

Share:

Related posts