Branching and Merging

List all branches

$ git branch --all
feature
master
experiment

List all branches but with tags and paths

$ git show-ref --heads
498567408764506745980 refs/heads/experiment
948576093760495764945 refs/heads/feature
498579486794857648596 refs/heads/master

Seeing that references:

$ cat .git/refs/heads/master
498579486794857648596 refs/heads/master

In order to delete the branch locally, it simply delete the reference file, but is not good.

To ensure that no references are left broken.

Deleting the branch (ONLY removes REFERENCE, but the commit it references is still there, but it is left dangling):

$ git branch -d experiment
// It warns about just delete non merge branch into master

// To force it
$ git branch -D experiment

To get the list of the dangling commits by using file system check (fsck) command

// All its ancestors are innaccesible
$ git fsck --dangling --no-progress

// to look for those ancestors inaccesible
$ git fsck --unreachable --no-progress

Unreachable commits can be recovered until a certain period of time from the branch's own journal called the reflog.

// Create a reference head for the commit
$ git branch experiment 4564564

Merging a branch

// in order to merge a branch into the one currently referenced by head
$ git merge feature -m "M"

Different kinds of branching

aa

results matching ""

    No results matching ""