DevOps/SRE engineers are often responsible for creating and maintaining automated workflows

Having knowledge of Git's advanced features enables you to work more efficiently.

So, let's take a look at the most useful Git commands to streamline your Git productivity.

🧵👇
I already explained what VCS are by using diagrams in another thread.

If you're interested, you can check out that post by looking at the tag in my last tweet.

This thread is for people who are already familiar with Git and want to improve their usage of it.

Let's begin!
1/

Here's a simple way to check your Git configuration

command:

git config -l

You'll get a list of your Git settings

Like your user name and email, and many more.
2/

If you want to force a push request in Git

command:

git push -f

It's generally okay to use this command

If you're working on a pull request branch.
3/

See your commit history, including changes made to files

command:

git log -p

This command will display a detailed history of all commits

Along with the changes made to each file.
4/

To view a specific commit in Git

command:

git show commit-id

To use this command, replace `commit-id` with the actual identifier of the commit that you want to view

You can find this identifier in the commit log, following the word commit
5/

View log statistics in Git

command:

git log --stat

Running this command will display some statistics about the changes made in each commit

Such as the number of lines changed and the names of the files modified.
6/

View and stage changes using Git

command:

git add -p

This will open a prompt asking if you want to stage the changes or not, and it will include other options.
7/

Remove tracked files from the current working tree in Git

command:

git rm filename

This command will remove the specified file from the Git repository and the working tree.

This command expects a commit message to be included, explaining why the file was deleted.
8/

rename files in Git

command:

git mv oldfile newfile

This command will stage the changes and rename the file from "oldfile" to "newfile".

This command also expects a commit message to be included.
9/

Revert unstaged changes in Git

command:

git checkout filename

This command will discard any changes made to the specified file that have not yet been staged.

The file will be restored to its previous state
10/

To modify and add changes to the most recent commit in Git

You can use the following command:

git commit --amend

Using this command will allow you to amend the most recent commit by modifying its message or adding changes to it.
11/

To rollback the last commit in Git

command:

git revert

This command creates a new commit that is the opposite of everything in the given commit

Effectively undoing the changes made in the previous commit.

To revert the latest commit

use the head alias

git revert HEAD
12/

Create a new branch in Git

command:

git branch branch_name

By default, you have one branch which is usually called the main branch.

This command creates a new branch with the name specified after branch_name.
13/

To create a new branch in Git and switch to it immediately

command:

git checkout -b branch_name

This command creates a new branch with the name specified after `branch_name`

It is a shortcut for the "git branch" and "git checkout" commands combined.
14/

Remove a branch in Git, after merging and completing work

command:

git branch -d branch_name

To delete the branch.
15/

Combine the history of two branches in Git

Simply follow these steps

Execute the command:

git merge branch_name

To merge the branch_name with the branch you are currently working in.
16/

Display the commit log as a graph in Git

Perform the following steps

Include the option `--graph`

when executing the command `git log`

This will allow you to view the commit log in a graph format.

Limit commit messages to a single line by using the `--oneline` option
17/

Cancel a conflicting merge in Git

command:

Execute `git merge --abort`

To discard the merge and begin again
18/

Include a remote repository in Git

command:

Execute `git add remote https://repo_here`

To add a remote repository to your local repository.

Simply replace `https://repo_here` with the URL of your remote repository.
19/

To find out more information about a remote repository in Git

first we want to run `git remote -v` to see the name of the remote.

Then, replace `origin` in the command `git remote show origin` with the name of the remote you want to learn about.
20/

If you want to update the contents of remote branches in Git

Without automatically merging them into your local branches

command:

git remote update command

You can choose to merge the content using the `git merge` or `git checkout` commands, as needed.
21/

To move finished work from one branch to another in Git

command:

git rebase

followed by the branch name you want to transfer the work to

For example, git rebase branch_name_here

Keep in mind that rebase can be complicated if not used correctly, be careful when using it
My mission is to guide people who want to get into DevOps, from basics to advanced!!

If you had a good time reading this please retweet the first tweet to help others as well.

VCS:



Have a Wonderful day!!

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Krishnamohan Yerrabilli ☸️

Krishnamohan Yerrabilli ☸️ Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @K_Mohan_

Mar 2
Whether in public or private conversations, asking good questions is important for personal and professional growth

It can help you build relationships and gain knowledge from others.

Here's how 🧵 Image
Based on my personal experience,I have learned that simply saying hello or hi can actually worsen a situation

Asking good questions can help you learn from experienced people and grow your career

This are the things you need to take care of, to get a good response.
📌Do your research first

Before asking a question, try to search for information on your own

This will show that you have put in effort and are not asking a question that has already been answered elsewhere.
Read 12 tweets
Feb 28
A solid understanding of the Linux file system and directory structure is critical for any DevOps/SRE engineer working in a Linux-based infrastructure.

It helps to navigate, manage, and automate operations more effectively.

Let's dive into the topic 🧵👇
To begin with, let's first understand what FHS or Filesystem Hierarchy Standard is.

It is simply a reference that describes the rules and guidelines for organizing a UNIX system.

It's maintained by the Linux Foundation

Which created 29 years ago in 1994 (yes, it's true).
I made a picture that shows the file system structure.

You can save it and look at it easily when you need to remember how directories are organized in Linux.
Read 25 tweets
Feb 26
Understanding Version Control Systems for DevOps/SRE Engineers.

A Visual Guide with Diagrams!!

🧵👇 Image
First, let's understand what VCS is:

Version control system,is simply a tool used by developers to manage changes made to the source code of a software project over time

We can create, edit, and save different versions of our code,track the changes made between versions Image
Types of VCS:

Let's see the first one, called CVCS or Centralized Version Control System

In CVCS, a central server is used to store and manage all versions of the files in a project. Image
Read 9 tweets
Feb 23
As a DevOps/SRE engineer, understanding Linux commands is crucial for efficient server management

So, let's dive into some of the most used Linux commands!!

🧵👇
First, we need to know what Is a Linux Command?

In Linux, a command is a program that runs on the Command Line Interface (CLI)

You can simply think of it as a command prompt on Windows.

you can perform tasks, such as installing packages, managing users, and managing files
1/23 sudo command

It is used to perform tasks that require administrative or root permissions

It prompts users to authenticate themselves with a password

syntax

sudo (command)

-k: Invalidates the timestamp file
-g or --group=group: Runs commands as a group
Read 26 tweets
Feb 21
Creating a More Connected World

The Story of CNCF and Cloud Native Computing

🧵👇
1/15 Intro

First,you need to understand what open-source free software is.

It is software that is made publicly available for anyone to use, study,modify, and distribute.

The term free in this context refers to the freedom to use the software in any way without any limitations
2/15 FOSS Example

The Linux kernel, created by Linus Torvalds, is a key example of open-source free software. By making the source code of the kernel public

Lead to a community of developers collaborating to create a reliable and innovative operating system.
Read 17 tweets
Feb 19
Understanding Linux Kernel for DevOps/SRE Engineers.

A Visual Guide with Diagrams!!

🧵👇
1/12 Intro

To begin with, it's important to understand that the Linux kernel is not a complete operating system on its own. Rather, it is a component of an operating system known as GNU/Linux

Which is the combination of the GNU project's userland tools and the Linux kernel.
2/12 General Layout of OS

Kernel Space is responsible for accessing and sharing the hardware. It runs important system functions with higher privileges

user applications run with lower privileges in a separate space. This distinction is important for maintaining security.
Read 15 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us on Twitter!

:(