Git in Real

Abhishek koserwal
3 min readFeb 8, 2019

--

This blog post is a tutorial series, which will help you to learn and practice scenarios which you will encounter more often as a day-to-day job use-case. This is post won’t going to cover the basic commands/concepts. Scenarios covered are cases are specific and happens often while working on a project or with a global team environment. Learn by doing is the main ideology behind this post. Try to practice each chapter and understand the concept.

Lessons:

  • Remotes
  • Amend
  • Merge-Conflicts
  • Log Tricks

Prerequisites

  • Github free account
  • Git installed in your system
  • Basic understanding of git concepts like git add, git commit and branching etc.

Once you are ready with above pre-requisites. We can start by cloning the repository into your system

git clone https://github.com/akoserwal/git-in-real

You will have to check out the branch corresponding to the topic you wanted to learn and practice.

Lesson 1: Remotes (branch: Ch1-remotes)

git checkout Ch1-remotes

Read the lesson-1 and follow the instructions

Lesson: 2 Amend: Rewriting history

git checkout Ch2-amend

Lesson 3: Merge Conflicts

git checkout Ch3-merge

Editors like VS-Code and GitHub UI provides an easier way to resolve merge conflicts.

As you can see in this picture. You can click on the options give above the lines where conflict occurs. Like: Accept Current Change | Accept Incoming Change | Accept Both Changes. So, you can automatically remove the non-required changes with a click on a button.

4 Logging-tricks: Find out when a particular file was changed:

git log --name-status --follow --oneline <filename>
README.md history

Finding out when and what happened between checking out branches

git reflog
reflog

5. Removing residue files (Remove untracked files from the working tree)

git clean -df

Often you see some files which are shown as untracked and when you got a git status:

.classpath
.factorypath
.project
  • For removing directories: git clean -f -d
  • For Ignored files: git clean -f -X
  • For removing ignored/non-ignored files: git clean -f -x.

I will keep updating this post. As I add more lesson. Thank you for reading. keep practicing and Coding!

--

--

Abhishek koserwal
Abhishek koserwal

Written by Abhishek koserwal

#redhatter #opensource #developer #kubernetes #keycloak #golang #openshift #quarkus #spring

No responses yet