Mastering Git

What to focus on?

    Today is a scary day. Today is the day of admitting one's faults and learning what I was supposed to long ago. So let's dig into learning curve all together by looking at a couple of Git functions I personally have never used before, which though, for some of you, might already be very familiar, so I will try to bring more interesting information about them to peak everyone's interest.
    What are the two functions that we will be looking at? Shall it be git fetch and git tag.

Let's play Fetch

    The purpose of git fetch is to download commits, files, etc. from a remote repo into user's local one (from here, and here). How is it different from git pull then? Well, git fetch does not necessary merge the content with the user's repo, but git pull does. The way to imagine it would be git pull = git fetch + git merge.

    Here is a graphical representation of the above:

    There are quite a few ways to run the command:
  • git fetch [<options>] [<repository> [<refspec>…​]]
  • git fetch [<options>] <group>
  • git fetch --multiple [<options>] [(<repository> | <group>)…​]
  • git fetch --all [<options>]/
    And some of the interesting options for the command are:
  • --all           - fetches all repos
  • --depth=<depth> - limits fetching to a particular number of commits
  • -k
    --keep          
    - keeps downloaded package
  • --multiple      - allows multiple repositories/groups to be specified as parameters
  • -q
    --quiet         
    - silences any internally used git command; progress does not get
                                             reported to standard error stream
  • --progress      - progress status gets reported on the standard error stream
  Examples of the usage can be found here.

Let' tag it

    Tagging is a process of creating a "bookmark", a label at a specific point of time, which represents the version at which the project is present. It can look like any of the following: v1.0, v0.1, v1.8.9-rls, etc. In order to see the current tags available, you can type git tag, git tag -l or git tag --list (source).
    In case if the are quite a few tags in the project, the list can be narrowed down by specifying which ones we want to see. For instance: git tag -l "2.95.*"
    There are to types of the tags present in Git:
  • Lightweight - they are somewhat similar to pointers to specific commits and don't take up much space.
  • Annotated - stored as objects; they contain tagger's name, date, message, they can be signed and valued.
    Examples of creating lightweight tags:
  1. git tag v0.1
  2. git tag v1.0-rls
  3. git tag v2.4.1

    Examples of creating annotated tags:
  1. git tag -a v1.5 -m "here comes a mandatory message for the tag"
  2. git tag -a v1.5.1 - after that command with no message body provided,
                                                Git will open an editor
    If you want to see a detailed information on an annotated tag, then git show should run:

          git show v1.5
          
    The function will display the following metadata:
    tag v1.5
    Tagger: Vlad Rozin <vlad.rozin@example.com>
    Date:   Sun Jan 27 10:10:00 2019 -0700

    my version 1.5

    commit fd10a5aaa817ec66f44789001618690a93761618
    Author: Mike Tyson <mike.tyson@example.com>
    Date:   Mon Jan 28 01:52:11 2019 -0700

        changed the version number


Comments

Post a Comment

Popular posts from this blog

Two Different Frames of Same VidioCapture

Node.js: fs.open()

Good friend penguinV