Create New Branch Only Contains Last N Commits

Sometimes we don’t need commit history from long time ago, and only want to keep last n commits. For example: Let’s say we want to perform this operation on our main branch, and backup the previous status as another branch main_old, then force push new main branch to the remote. The PowerShell script above willContinue reading “Create New Branch Only Contains Last N Commits”

Shallow Git Repository

Create Shallow Repository Just run shallow fetch command: Unshallow Checkout official doc for more info. Remove Unused Remote Branch Update Fetch Config We can edit the git config file to determine which branches should be fetched automatically. As you see, we could change the fetch config in the remote section to tell Git which branchContinue reading “Shallow Git Repository”