12/11/2023 0 Comments Git delete branch local onlyIn any cloned repositories, to do a âforcefulâ pull, run the following commands. The suggested method of rebasing/squash merging will get rid of these commits. Same for C because it is pointed to by D and so on. The commit E still points to D so this commit will not be deleted by the git garbage collection. So deleting a branch just frees up some bytes. We can make Git forcefully resetting the cloned repositories too. A 'branch' is merely a label for a commit. ![]() One consequence of clearing (or changing) history of a Git repository is that we have to forcefully update other cloned repositories which contain the old Git history. Git gc -aggressive -prune=all # remove the old files Reset other existing Git repository clones after the branch is cleared git branch -set-upstream-to=origin/master master # Local master tracks origin/master We can add the remote master branch tracking and do a garbage collection in the operating repository as follows. The repository we are operating has the new branch metadata and some garbage files. ![]() Git push -f origin master # Force push master branch to Git server Book keeping in the operating Git repository clone Git branch -m master # Rename the current branch to master Git branch -D master # Deletes the master branch Git add -A # Add all files and commit them git checkout -orphan tmp-master # create a temporary branch The commands are as follows, operating in a cloned repository. force push the master branch to the Git serverÄ«ecause the new master branch has only one commit, after the master branch is force pushed to the Git server, the master branchâs history is âclearedâ. A shorter version of the command is below: git fetch -p. Another version of the same command is: git fetch -prune This will delete all the obsolete remote-tracking branches.git remote prune origin 'deletes the refs to the branches that dont exist on the remote. rename the temporary branch to be the master branch Now, you need to delete the local references too.add all files into the temporary branch and commit.To clear the history of the master branch, we can do the operations of: ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |