Git: Fix differences created by line endings in files

This article explains the issue created by line endings in code in different OS versions and also provides solutions to fix the issue by normalizing the line-endings in files. Introduction Files created/edited on Windows OS and Mac/Linux OS can have different line endings. Suppose, a developer (Dev1) created a file in Windows OS and pushed … Read more

Git: Create & Apply Patch using format-patch

Previously, I had written an article to create and apply patches using the git diff and git apply commands. In this article, we will look into alternative git commands to create and apply git patches. Those commands are git format-patch (to create patch) and git am (to apply patch). Check commits in your branches Checkout … Read more

Git: Diff, Create & Apply Patch

This article shows how you can get differences in the git branch, file, or commits and create and apply git patches. > git branch master * test > git checkout test > git log –oneline -n 5 04d3d11 (HEAD -> test) Update README 39fdf70 Update hello file 32547fa Add hello file 87ea803 (origin/master, origin/HEAD, master) … Read more

Git: Pull remote branch from someone else’s Fork

There can be a scenario where you would need to continue working on the work done by someone else on your team. In such a case, you can pull your team member’s fork branch and continue working on whatever is done in that team member’s branch. You can add your code changed and push it … Read more

Git: Reset to older commit / Undo changes & Push

This article shows how you can reset your git state to any older/previous commit and then push to your origin repository. Reset to older commit git reset –hard <commit-hash> Example: git reset –hard 39fdf70 Force push to origin repository git push origin –force # OR git push –force If you only want to reset in … Read more

Git: HEAD, Detached HEAD & Reset HEAD

What is Git HEAD? “HEAD” is an alias for your current working commit. It’s the latest commit of your currently checked out branch. If you checkout a another branch then HEAD will be the latest commit in that particular branch. Check Git HEAD status The following shows that the working directory is the tip of … Read more

How to use Diff command to create Patch?

This article shows how you can create a diff patch file that can be used in Git repositories. The diff command line tool shows the difference between the two files. Such a difference between the two files is called a patch. The diff syntax is: diff [options] [original filename] [changed filename] diff [options] [original directory] … Read more