Myrl  Prosacco

Myrl Prosacco

1595492700

A simple solution to revert a git commit that has been pushed to master branch

Today I will tell you a different git story.

Committing mistakes are far better than committing suicide. Is not it?

There’s a girl named Silvia, she was brilliant but sometimes she made silly mistakes while committing her files. She always used to face challenges while committing. One day she made a huge mistake on a production ready branch. She committed her recent changes into a master branch instead of dev branch, the branch where all the developments occurs.

She was so nervous, she informed me that mistake of her.

As being her lead it was my responsibility to correct her mistake . So I told her to undo that commit using git reset.

She was not sure what will be the command for that. Again she asked me, I pinged her this command

Image for post

#illustration #git #commit #coding

What is GEEK

Buddha Community

A simple solution to revert a git commit that has been pushed to master branch
Myrl  Prosacco

Myrl Prosacco

1595492700

A simple solution to revert a git commit that has been pushed to master branch

Today I will tell you a different git story.

Committing mistakes are far better than committing suicide. Is not it?

There’s a girl named Silvia, she was brilliant but sometimes she made silly mistakes while committing her files. She always used to face challenges while committing. One day she made a huge mistake on a production ready branch. She committed her recent changes into a master branch instead of dev branch, the branch where all the developments occurs.

She was so nervous, she informed me that mistake of her.

As being her lead it was my responsibility to correct her mistake . So I told her to undo that commit using git reset.

She was not sure what will be the command for that. Again she asked me, I pinged her this command

Image for post

#illustration #git #commit #coding

Myriam  Rogahn

Myriam Rogahn

1599234420

GitHub for Data Scientists: Commit

This article is part of a follow-along series on GitHub collaboration. In this article, we will try to understand commits in detail, like components of a commit, how to delete commit before and after push or how to reset it.

If you are a beginner and want to understand the practical application, I will recommend a quick read into the article, Collaborate on GitHub like Pro: **Part1 **before you start with this article.

The series, Collaborate on GitHub like pro, focus on specific topics:

  1. Getting started on GitHubCollaborate on GitHub like Pro: Part1
  2. **Branching: **Collaborate on GitHub like Pro: Part2
  3. **Commit: **Collaborate on GitHub like Pro: Commit

What is a commit?

Commits are created with the git commit command to capture the state of a project at that point in time. When you make a commit, Git stores a commit object that contains a pointer to the snapshot of the content you staged (indexed), please see below commit stage highlighted in red box.

Image for post

Commit flowchart

Components of a commit:

Let us take a look into the commit object, shown below. I have highlighted the three main components in the commit, hashhead and branch (master).

Image for post

Image for post

Commit Object

Hash: Every commit creates unique hash for the respective commits. These hashes can later be used to revert to that version or find details on the commit. Usually, only the first 7 characters are used to look for respective commit.

Head: Shows which branch you are working on currently. In the above image, head is pointing to master, which means currently you are working on the master branch.

**Branch: **By default, the first line of development (branch) is named as master. All the preceding work on different branches gets merged to master.

To understand this concept further refer to this blog post.

Image for post

Master branch after three commits

Switch to a specific commit

There are multiple ways to checkout to a specific commit based on the use cases. You might want to make a temporary or permanent switch. Sometimes you might want to go a few steps back and maybe add a feature from that step onwards.

#commit-git #git-revert-commit #checkout-git #show-heads #git-delete-branch

Madyson  Reilly

Madyson Reilly

1604109000

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

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

Royce  Reinger

Royce Reinger

1617382740

Branching Out and Deleting Branches

It is good practice to create git branches to code on before merging it back into the master branch but did you know that you should also consider deleting those old branches?

I was cleaning up my code when it crossed my mind on whether it’s ok to reuse a git branch after merging it in with the master.

In my quest for a clear answer it turned out that I needed a better understanding of some key concepts like: Git, commits, branches and so on.

What Is Git?

It’s a version control system for source code management where each copy or repo of the code has the full history of commits and changes.

Basically, you can work on multiple versions of a project each with their own branch. Imagine several branches running parallel to each other.

Branches running parallel

#git #git-merge #coding #git-commands #git-branch