Home / Notes / Git Notes
========================

1. git - The Simple Guide

2. Renaming a Repository

3. Working with Branches:

    a. List local branches:

        $ git branch

    b. List remote branches:

        $ git branch -r

    c. List all branches:

        $ git branch -a

    d. List current branch:

        $ git rev-parse --abbrev-ref HEAD

    e. Delete local [branch]:

        $ git branch -D [branch]

    f. Delete remote [branch]:

        $ git push origin --delete [branch]

    g. Synchronize local branches with remote branches:

        $ git fetch -p

    h. Rename local branches:

        $ git checkout master
        $ git branch -m [current_name] [new_name]

    See: https://infoheap.com/git-list-branches/
         https://stackoverflow.com/questions/1417957/#1418022
         https://www.freecodecamp.org/news/how-to-delete-a-git-branch-both-locally-and-remotely/
         https://stackoverflow.com/questions/2003505/
         https://www.hostinger.com/tutorials/how-to-rename-a-git-branch

4. Rebasing Commits

    a. To rebase a commit, count the number of commits from the first
       commit to the last commit that you want to rebase then run git
       rebase as follows:

        $ git rebase -i HEAD~[num]

       [num] is the number of commits from the first commit through
       the last commit to be rebased, inclusive.

    b. In the editor that opens, mark the first commit as 'pick', and
       and the remaining as 'squash'

    See: https://www.git-tower.com/learn/git/faq/git-squash/

5. Signing failure for commits

   If the following error appears, it is probably due to a hung
   gpg-agent:

    error: gpg failed to sign the data
    fatal: failed to write commit object

   gpg-agent can be restarted as follows:

   $ gpgconf --kill gpg-agent

   See: https://stackoverflow.com/questions/41052538