What is Git?

Git is an open-source, widely-used version control system for code repositories. Git used to safely make changes to their codebases, track those changes across time, and combine or even undo changes made If required.

Git is a version control system that allows you to track changes made to files while working on a project, either independently or in collaboration with others. It provides a way to save many different components of a project in progress, including the source code, but also the figures and data that the code produces. The importance of understanding and using Git lies in its ability to maintain an organized record of a project, also referred to as a repository or repo.

Github is where just about every developer out there stores his or her portfolio and it’s where your next job is likely to host their code as well.

  • Add/Commit All

One of the most common things you will do when working with Git is adding and committing a bunch of files at once. The standard way to do this is usually running an add command followed by a commit.

git add .
git commit -m “Message”

This works fine, but you can actually combine this into one command.

git commit -a -m “Message”

By using the -a flag when committing you are telling Git to add all files that have been modified and then commit them. This runs into issues with new files, though. Since the -a flag only adds modified files it will not add new files or deleted files. Unfortunately, you cannot use commit to add these types of files, but you can use the -A flag with add to add them all.

git add -A
git commit -m “Message”

By using this command you can now add all files even if they are new or deleted. You will also notice this command is very similar to the first git add . command. The only difference is that using -A will add all files within the repository while using the . will only add all files in the current folder your terminal is open to. This is why I always recommend using -A if you want to add all files in the repository.

  • Aliases

In the previous section we talked about how you can add and commit all files, but it requires two commands and is bulky to write out especially considering it is something you will be doing all the time. That is where Git aliases come in. With aliases you can write your own Git commands that do anything you want. Let’s take a look at how you would write an alias for the above add/commit command.

git config –global alias.ac ‘!git add -A && git commit -m’

With this simple line we are modifying our global Git config and adding an alias called ac which will run the command git add -A && git commit -m. The code looks a bit confusing, but the result is that I can now run git ac “Message” and it will do the full add and commit for me.

Now lets breakdown how this works. The first part of the command is git config –global. This just says we are modifying our global Git config since we want this alias to be available in any Git repository.

The next part is alias.ac. This says we want to create an alias called ac.

Finally, the last part is the full command !git add – A && git commit -m. This is just our normal Git command, but we have prefixed the command with an exclamation point. The reason for this is that a Git alias by default assumes that you will be calling one single git command, but we want to run a command that is more complex than a single Git command. By prefixing our command with an exclamation point Git will not assume we are running one simple command. To explain this further here is an example of creating an alias for git commit -a -m “Message”

git config –global alias.ac “commit -a -m”

As you can see we are just calling a single simple Git command so we can leave out the word git and since we have no exclamation point at the start of our command Git will assume that we are trying to call a single Git command and will add the git for us.

  • Revert

The last two commands have been pretty complex so let’s look at a really simple command. The revert command simply allows us to undo any commit on the current branch.

git revert 486bdb2

All you need to do is pass the commit you want to revert to the command and it will undo all changes from that commit. One important thing to note, though, is that this only undoes changes from that exact commit. If you do a revert on a commit from a month ago it will not undo all changes made since that commit. It will only undo the changes in that exact commit.

Another important thing to note is that using revert does not actually remove the old commit. Instead it creates a new commit that undoes all the changes from the old commit. This is good since it will preserve the history of your repository.

One common trick is to revert the most recent commit which can be done with the following command

git revert HEAD

  • Reflog

Another simple, but useful command is reflog. This command lets you easily see the recent commits, pulls, resets, pushes, etc on your local machine. This is a great way to track down any issues that may have come up to see what you did to cause those issues.

git reflog

Reflog Output

  • Pretty Logs

Another useful logging command in Git is the log command. This command combined with some special flags gives you the ability to print out a pretty log of your commits/branches.

git log –graph –decorate –oneline

Log Output

  • Searching Logs

You can also use the log command to search for specific changes in the code. For example you can search for the text A promise in JavaScript is very similar as follows.

git log -S “A promise in JavaScript is very similar”

This command returns to me the commit where I added the article on JavaScript promises since that is the commit where I added this text.

  • Stash

How many times have you been working on a feature when an urgent bug report comes in and you have to put all your current code on hold. It is very tempting to do a simple add/commit with a WIP message so you can switch branches to the main branch before fixing the bug, but this clogs up the commit history and is not ideal. Instead, the best thing you can do is use a stash.

git stash

This simple command will stash all your code changes, but does not actually commit them. Instead it stores them locally on your computer inside a stash which can be accessed later. Now you can go about fixing the urgent bug and once you are done with that you can pop your changes from the stash to continue working.

git stash pop

This command will take all the changes from the stash and apply them to your current branch and also remove the code from the stash. This is the ideal workflow if you need to quickly stop working on your current code to start working on something more urgent.
8. Remove Dead Branches

If you are working on any decent sized project odds are your repository has tens or hundreds of branches from previous pull requests. Most of these branches have probably been merged already and are deleted from the remote repository, but they are still on your local machine. This can get annoying when you have hundreds of dead branches on your machine which is where this command comes in.

git remote update –prune

This command will delete all the tracking information for branches that are on your local machine that are not in the remote repository, but it does not delete your local branches. In order to do that you need to run a bit of a tricky command.

git branch -vv | awk “/: gone]/{print $1}” | xargs git branch -d

This command will list out all of your branches and then search for any branches that have the remote tracking set to gone. This gone status is set from the previous command where we removed the tracking information for branches that no longer exist in the remote repository. Then we are grabbing the branch name for the deleted branch with the {print $1} command and passing that to git branch -d which will delete the branch for that name.

This is a pretty complex command which is why I recommend combining the previous two commands into one simple git alias that can do all this for you.

git config –global alias.prune ‘git remote update –prune && git branch -vv | awk “/: gone]/{print $1}” | xargs git branch -d’

  • Bisect

The bisect command in Git is incredible for finding which commits caused certain bugs. It is very common for a repository to have thousands of commits from hundreds of developers so when a bug report comes in it can be tricky to track down which changes caused this issue. With bisect, though, this problem is trivial. In order to understand why this command is so amazing let’s look at how to use it.

git bisect start
git bisect bad
git bisect good 48c86d6

To start a bisect you need to run three commands. The first command starts the bisect. The second command tells Git which commit is the bad commit with the bug. If you leave this blank, as we have, Git will just use the latest commit. The final command tells Git which commit is known to not have this bug. In our example, we know that in commit 48c86d6 there is no bug.

Now after you run these three commands Git will choose the commit in the middle of these two commits and grab all the code from that commit. You can then test to see if the bug is in this commit or not. If the bug is present you just type git bisect bad and it will select the commit that is halfway between this bad commit and the last good commit. If the bug is not present then you can type git bisect good and Git will select the commit that is halfway between this good commit and the last bad commit. You keep repeating this process of typing either good or bad until eventually, you are able to narrow it down to the exact commit that caused the bug.

This is amazing at narrowing down your bug search since some bugs can be really hard to track down without knowing what code was changed to cause it.

  • Destroy Local Changes

Sometimes you make changes and realize that you need to scrap everything you have done so far. This usually isn’t a big deal if you haven’t committed yet, but if you have made multiple commits it can be hard to exactly remove all changes. This is where the reset command comes in. By running the below command you can wipe out all changes on your local branch to exactly what is in the remote branch.

git reset –hard origin/main

The above command says to forcefully delete all local changes on your current branch and replace them with the code from the main branch in the remote. It is important to note that this will remove all local changes you have made so only do this if you really want to delete all the changes you have made and need to start fresh.

Download and install the latest version of Git.

Know About Linux containers

Containers allow a developer to package up an application with all of the parts it needs, such as libraries and other dependencies, and ship it all out as one package. And they are designed to make it easier to provide a consistent experience as developers and system administrators move code from development environments into production in a fast and replicable way.

In short, Linux containers, contain applications in a way that keep them isolated from the host system that they run on.

In a way, containers behave like a virtual machines. To the outside world, they can look like their own complete system. But unlike a virtual machine, rather than creating a whole virtual operating system, containers don’t need to replicate an entire operating system, only the individual components they need in order to operate. This gives a significant performance boost and reduces the size of the application. They also operate much faster, as unlike traditional virtualization the process is essentially running natively on its host, just with an additional layer of protection around it.

And importantly, many of the technologies powering container technology are open source. This means that they have a wide community of contributors, helping to foster rapid development of a wide ecosystem of related projects fitting the needs of all sorts of different organizations, big and small.

Container add security by isolating applications from other applications on a host operating system, but simply containerizing an application isn’t enough to keep it secure.

the Docker open source project, a command line tool that made creating and working with containers easy for developers and sysadmins alike, similar to the way Vagrant made it easier for developers to explore virtual machines easily.

Containers provide an isolated view of the system resources to the applications. In order to provide this contained view to the applications, Containers use some of the kernel features called namespaces, cgroups and chroot to carve off a contained area. An end result is a virtual machine without the hypervisor. Containers are a smart method of attaining isolation and resource control.

Interesting Alternatives to Some of the Classic Linux Commands

Legacy commands were created several decades ago and while they do their intended jobs, their functionalities could be improved and the structure could be simplified.

This is why there exist ‘alternative’ tools that enhance the legacy UNIX/Linux commands. In this article, I am going to list some new CLI tools that you could use in place of the good old classic Linux commands.

HTTPie: Alternative to wget and curl

When it comes to downloading files in terminal, wget and curl are the two of the most common tools. Interestingly, not all distributions have curl, wget installed by default.

HTTPie does the same job but in a more human-friendly way. You have colorized, the formatted output which makes it easier to understand and debug.

Bat: Alternative to cat

The cat command is perhaps one of the first commands you learn. It does the job for viewing the contents of small text files.

But bat command takes it to the next level by adding features like syntax highlighting and Git integration. The pagination option is also available.

ncdu: Alternative to du command

The du command in Linux is used for checking the size of a directory. It’s not very straightforward command and it certainly doesn’t give a very good default output.

Compared to that, ncdu is a lot better than providing the relevant information at the first glance.

There are other features here such as showing the disk usage in graphs, sort the display and even delete directories interactively.It is based on ncurses and hence the ‘nc’ is added to ‘du’. A similar CLI tool is gdu which is a du replacement written in Go which gives it a performance boost.

fd: Alternative to the find command

The find command is one of the most powerful and most used Linux commands. It’s impossible to imagine that a sysadmin could survive without using the find command.

But the find command has a strange structure and it could be slow if you do a large set of find operations. A better and faster alternative is fd command. Written in Rust, fd is simpler and faster than its legacy competitor.

exa: Alternative to ls command

The exa CLI tool adds a few features while listing directory contents. It has better defaults and uses colors to distinguish file types and metadata. exa can also display a file’s extended attributes, as well as standard filesystem information such as the inode, the number of blocks, and a file’s various dates and times.

You can use the tree view to see directory structure. It also has built-in Git support to see what files have changed, committed and staged etc.

Duf: Alternative to the df command

The df command in Linux is used for checking disk space. While it works most of the time, an easier and better alternative is duf, a tool written in Go.

It gives you an overview of all the devices mounted which is easy to understand. You also have the ability to specify a directory/file name and check free space for that mount point.

With duf, you can sort the output, list indoe information and even save the output in JSON format.

 

Google and Microsoft Cloud Solutions Compared

Google and Microsoft Cloud Solutions Compared

Microsoft 365

Many PC users will already be familiar with many applications from the Microsoft 365 suite. Word, Excel, and PowerPoint are some of the most well-known programs in the world and are part of the standard equipment in many offices. Microsoft 365 enables software solutions to be used in the cloud. This simplifies working on the go and transforms traditional office applications into modern collaboration tools.

Advantages Disadvantages
✓   Popular Office applications X   Complex licensing system
✓   Cloud and desktop solutions X  
✓   Extensive opportunities for collaboration X  
✓   Cloud storage included X  

Google Workspace

Google has been offering more than just its search engine for a while now. Office solutions were also part of its product portfolio relatively early on. Back then, Google was actually one of the first to offer spreadsheets, word processing, and the ability to create presentations via a web application in the browser. By integrating Gmail and Google Drive, the individual programs in the meantime, it has grown into a comprehensive suite that is completely in the cloud.

Advantages Disadvantages
✓   Device-independent operation X   No desktop version
✓   Professional email domain included in Gmail X  
✓   Extensive opportunities for collaboration X  
✓   Cloud storage included X  

Google and Microsoft cloud solutions compared

With the productivity software Google Workspace, Google is targeting the business segment – a declaration of war to market leader Microsoft and their competitor product Microsoft 365.

App feature Microsoft 365 Google Workspace
Word processing Microsoft Word Google Docs
Spreadsheet calculation Microsoft Excel Google Sheets
Presentations Microsoft PowerPoint Google Slides
Email Microsoft Outlook Gmail
Digital notepad Microsoft One Note Google Keep
Web hosting Microsoft Sharepoint Google Sites
Video conferencing Skype for Business Google Meet
Instant messaging service, group chats Microsoft Teams, Skype for Business Google Chat
Chat-based workspace Microsoft Teams Google Chat
Social Media for companies Yammer Google Currents
Office applications as web apps Yes Yes
Offline operation possible Yes Yes
Cloud storage & file sharing Microsoft 365 Google Workspace
Storage capacity per user license 1 TB Depending on the plan 30 GB, 1 TB, 5 TB or unlimited
Synchronization Yes Yes
Versioning Yes  
File sharing via link including expiration date Yes Yes
Search function Yes NLP supported
Collaboration Microsoft 365 Google Workspace
Business suitable appointment and contact management Yes Yes
Joint editing of texts, tables, and presentations Yes Yes
Video calling Yes Yes
Instant messaging Yes Yes
Group chats Yes Yes
Video conferencing Yes Yes
Internal company websites/Intranet Yes Yes
Social Media for companies Yes Yes
Email Microsoft 365 Google Workspace
Ad free Yes Yes
Includes your own email domain No Yes
Mobile app Yes Yes
Desktop mail client included Depends on plan No
Email aliases Yes Yes
Groups/Email distributors Yes Yes
Security & data security Microsoft 365 Google Workspace
Data encryption Yes Yes
ISO /IEC 27001 (Information security) Yes Yes
ISO /IEC 27017 (cloud security) Yes Yes
ISO 27018 (cloud privacy) Yes Yes
SOC 1 Yes No
SOC 2 Yes Yes
SOC 3 Yes Yes
FedRAMP Yes Yes
PCI DSS (security standard for credit card transactions) Yes Yes
HIPAA BAA Yes Not all applications
Support & availability Microsoft 365 Google Workspace
High availability 99.9 % 99.9 %
24/7 support Yes Yes
Telephone Yes Yes
Chat/Email Yes Yes