Go Over Git

Linus designed GIT to first, each file needs to be edited along the time line, so need to have a magical filing cabinet where: You can instantly jump to any point in time; Every change creates a snapshot (commit); second, the Linux kernel needed thousands of developers to collaborate without chaos. Traditional systems had a bottleneck – one central server. Git eliminated that by making every repository a complete, independent entity.

Now how to use it?

First, git init, it creates a hidden .git/ folder in your directory containing:

  • objects/ – Where all file snapshots are stored (as compressed blobs)
  • refs/ – Pointers to commits (branches, tags)
  • HEAD – Points to your current branch
  • config – Repository settings

Then, git checkout main to switch to a “parallel” universe of the project.

git remote add origin <url> – Connects to other universes, for example, git remote add origin https://github.com/user/repo.git, it literally mean “Hey Git, I want to add a new ‘remote’ connection. I’m going to call this remote origin, and its location (URL) is https://github.com/your-username/your-repo-name.git on GitHub. Now that you know about origin, when I tell you to push or pull, you’ll know where to send or get the code from.” behind the scene, it stores the URL in .git/config under the nickname “origin” Doesn’t transfer any data – just creates a bookmark.

git commit -m “Add feature”, Creates a permanent snapshot of your staged files Generates a unique hash (like a1b2c3d...) for this exact state Links it to the previous commit, creating a chain Updates your current branch pointer to this new commit.

Finally, git push origin main. Sends your new commits to the remote repository Updates the remote’s “main” branch to match yours. git pull origin main – Downloads from other universe

GIT tag is an effective way to do the versioning of codes, in my case, yaml file for methodology tracking.

# Working on your config files...
echo "new feature" >> config.yaml

# Commit the work FIRST
git add config.yaml
git commit -m "Add new authentication feature"
# ^ This creates a commit with ID like a1b2c3d

# NOW tag that commit  
git tag -a v2.0.0 -m "Version 2.0.0 - Authentication release"
# ^ This creates a tag pointing to commit a1b2c3d

What if you want to tag the old commits

# See your commit history
git log --oneline
# a1b2c3d Fix critical bug
# b2c3d4e Add new feature
# c3d4e5f Initial setup

# Tag that old "Initial setup" commit
git tag -a v1.0.0 -m "Version 1.0.0 - Initial release" c3d4e5f

What if the annotation was wrong, need to be fixed,

# Try to edit the tag annotation (not available in all Git versions)
git tag -a -f v2.0.0 -m "Version 2.0.0 - Fixed annotation message"

What if the tag was wrong, we need to delete and create a new one,

# Delete the incorrect tag
git tag -d v2.0.0

# Create new tag with correct annotation
git tag -a v2.0.0 -m "Version 2.0.0 - Authentication system with OAuth support"

How to view the tags, use “git show V3”,

use “git tag -n99”

in github web page, look for release tags:

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.