Hermann  Frami

Hermann Frami


Understanding the Fundamentals of Git

Understanding various Git Objects which operate under the hood

Git is a powerful tool, but it can be overwhelming especially for newcomers. Even for experienced developers, getting stuck in a merge or a rebase conflict is pretty common. Even with extensive blogs available, it can be sometimes tricky to identify the cause, ultimately ending up wasting our productive time.

There are a plethora of tutorials out there already, but most of them simply talk about high-level user commands, syntax, and how to use them abstracting out most of the internal details.

This article tries to uncover how Git works under the hood. But why should we even bother about that? Knowing how it works from the ground up can help a great deal in using the commands. Since it’s not about learning the commands, instead it’s about learning the conceptual model. So, instead of learning a bunch of commands, we will try to understand how the commands work. Once we start to understand it, we’ll be more and more comfortable and confident in using the commands, and eventually, we’ll start enjoying it. Besides, there is always a geeky pleasure in knowing the internals. With this, let’s demystify git.

Git — A Stupid Content Tracker (as documented in man git)

At its very core, git is a simple key-value store, a simple structure that maps keys to values and this structure is persistent i.e. it’s stored in our disk. The values are just sequences of bytes. It can be any kind of content, be it a text file or binary file, etc. We can provide a value to git and git will calculate a unique key for it, which can be used later to retrieve the content.

As a demonstration, we’ll use the hash-object command, which takes some data and gives back the unique key. Since hash-object does not operate directly on string data, we’ll have to pipe the input and pass the — stdin flag to let hash-object know. (hash-object is one of the plumbing commands, it’s totally fine if it’s not used by you before)

$ echo "Hello Sarah" | git hash-object --stdin

The above-generated hash will be used as a key to store that content. It is generated using the SHA1 algorithm. To dig deep into SHA1, you can refer here. The important point to note is, for the same sequence of bytes, we’ll always get the same hash every time on every operating system. And it’s almost impossible that we’ll get the same hash for two different content.

#git #programming

What is GEEK

Buddha Community

Understanding the Fundamentals of Git
Madyson  Reilly

Madyson Reilly


Best Practices for Using Git

Git has become ubiquitous as the preferred version control system (VCS) used by developers. Using Git adds immense value especially for engineering teams where several developers work together since it becomes critical to have a system of integrating everyone’s code reliably.

But with every powerful tool, especially one that involves collaboration with others, it is better to establish conventions to follow lest we shoot ourselves in the foot.

At DeepSource, we’ve put together some guiding principles for our own team that make working with a VCS like Git easier. Here are 5 simple rules you can follow:

1. Make Clean, Single-Purpose Commits

Oftentimes programmers working on something get sidetracked into doing too many things when working on one particular thing — like when you are trying to fix one particular bug and you spot another one, and you can’t resist the urge to fix that as well. And another one. Soon, it snowballs and you end up with so many changes all going together in one commit.

This is problematic, and it is better to keep commits as small and focused as possible for many reasons, including:

  • It makes it easier for other people in the team to look at your change, making code reviews more efficient.
  • If the commit has to be rolled back completely, it’s far easier to do so.
  • It’s straightforward to track these changes with your ticketing system.

Additionally, it helps you mentally parse changes you’ve made using git log.

#open source #git #git basics #git tools #git best practices #git tutorials #git commit

7 Best Practices in GIT for Your Code Quality

There is no doubt that Git plays a significant role in software development. It allows developers to work on the same code base at the same time. Still, developers struggle for code quality. Why? They fail to follow git best practices. In this post, I will explain seven core best practices of Git and a Bonus Section.

1. Atomic Commit

Committing something to Git means that you have changed your code and want to save these changes as a new trusted version.

Version control systems will not limit you in how you commit your code.

  • You can commit 1000 changes in one single commit.
  • Commit all the dll and other dependencies
  • Or you can check in broken code to your repository.

But is it good? Not quite.

Because you are compromising code quality, and it will take more time to review codeSo overall, team productivity will be reduced. The best practice is to make an atomic commit.

When you do an atomic commit, you’re committing only one change. It might be across multiple files, but it’s one single change.

2. Clarity About What You Can (& Can’t) Commit

Many developers make some changes, then commit, then push. And I have seen many repositories with unwanted files like dll, pdf, etc.

You can ask two questions to yourself, before check-in your code into the repository

  1. Are you suppose to check-in all these files?
  2. Are they part of your source code?

You can simply use the .gitignore file to avoid unwanted files in the repository. If you are working on more then one repo, it’s easy to use a global .gitignore file (without adding or pushing). And .gitignore file adds clarity and helps you to keep your code clean. What you can commit, and it will automatically ignore the unwanted files like autogenerated files like .dll and .class, etc.

#git basics #git command #git ignore #git best practices #git tutorial for beginners #git tutorials

Loma  Baumbach

Loma Baumbach


Mirroring Git Changes From One Server to Another Server


Hello all, nowadays most of the development teams using GIT version control, some of you may have a requirement of mirroring your team’s git changes from one server to another Git server. This article will help you to achieve the Git mirroring between one server to another server.

Business Case

I got one assignment wherein there will be 2 Git Servers, development will happen in one Git server and the changes should be synchronized to another Git server at regular intervals. But in my case, the complexity is both the servers are in different restricted network. So I have done the small experiment and it worked. And I am sharing the steps to you all in this article.

The Experiment Performed Using Below 2 GIT Servers

Main GIT Server: Let’s take our main git server is located in our office and can be accessed only in-office network.

**Mirror GIT Server: **The mirror server is located at the vendor/client-side, which can be accessible in a normal internet connection but not with our office network. Since the office proxy will block the outside URL’s.

#devops #git #git and github #git best practices #git cloning #git server

Rupert  Beatty

Rupert Beatty


Git Commands You Can Use To Dig Through Your Git History

In this short article, we’ll be exploring some quick  git commands that can help us in digging through our repositories’ history of commits. We’ll look at

  1. git log
  2. git shortlog
  3. git show
  4. git rev-list

#git #git-log #git-commands #git-history #aws

Git Rebase Tutorial and Comparison with Git Merge

There are many ways of working with git, if they’re clean, and don’t do damages, probably most of them are good.

But same as space vs. tab, in the IT world is a war between fans of rebase, and fans of git merge.

There are tons of arguments about:

-Which way is better?

-Which one is cleaner?

-Which is more comfortable?

-Which one gives a cleaner git graph?

-Why it’s important, and which one is more dangerous?

#quick help #tutorials #git #git branch #git commit #git interactive rebase