Save your changes temporarily in Git using Git Stash

This happens almost every now and then. You are in middle of working on some code changes, modified few files here and there and may be added new files. Now something else comes up urgently and you are asked to do it now. But you do not want to make a commit in middle of the work. In such a case, if you switch branch, your changes are carried over to the another branch as well. So you need a way to save your work temporarily. Fortunately, Git allows this functionality using what is known as Git Stash.

Stashing takes the dirty state of your working directory — that is, your modified tracked files and staged changes — and saves it on a stack of unfinished changes that you can reapply at any time.
Continue reading “Save your changes temporarily in Git using Git Stash”

Fixing error with .gitignore file not ignoring files

This happens almost every now and then with the developers who are very new to the Git. I’m writing it down in the hope that if somehow the original post on stackoverflow is not available for one or other reasons, people can still find the solution. Also, even after fixing this for multiple times, I do not remember the exact commands, I still end up googling the solution. Sometimes, it takes a lot of time to find the original post as there are so many reasons for .gitignore file not working in intended ways. So the scenario is like this, that you are very new to Git or have some understanding of Git or you are very excited about an idea, you started coding on it, then you initialize and then commit your files. Continue reading “Fixing error with .gitignore file not ignoring files”

Delete Branches in Git using commands

In git workflow, the ideal strategy to work is to fork a new branch, make changes and finally merge in the main development branches. Over the time, this results in creation of large number of branches which are not required and becomes stale. Although a branch is just a pointer to an commit and does not require more than 40 bytes of disk space, it can be painful to search a long list of branches and deciding what you want to work on. Also since we humans are not good with creating unique names for branches, they can also result in confusion.

Below are some steps to clean branches from git repository to remove the clutter. Continue reading “Delete Branches in Git using commands”

Understanding Git Cherry-pick and how it is useful

Git Cherry-pick is used by many Organizations as an alternative to the rebase and merge. Cherry-pick is used to copy selective commits from one branch to another branch. Unlike a merge or rebase, cherry-pick only brings the changes from the commits you select, instead of all the changes in a branch. You can also choose whether to apply only one commit from another branch or a number of commits from another branch.

Why Git Cherry-pick

Cherry-pick is a great way to tackle below common problems:

  1. Accidentally committing on the wrong branch. In this case, one can use git Cherry-pick to apply the change(s) over to the correct branch and then reset the original branch to the previous commit. Continue reading “Understanding Git Cherry-pick and how it is useful”

Understanding Git Garbage Collection

Garbage collection is a well known software practice. The garbage collector, or just collector, attempts to reclaim garbage, or memory occupied by objects that are no longer in use by the program. When we talk about the Git Garbage Collection, we mean almost the same thing. Git garbage collector runs a number of housekeeping tasks within the current repository, such as compressing file revisions (to reduce disk space and increase performance), removing unreachable objects which may have been created from prior invocations of git add, packing refs, pruning reflog or stale working trees.
Continue reading “Understanding Git Garbage Collection”

Working with Git and Visual Studio – Use Git Rebase inside Visual Studio

This blog post is part of in-depth blog series on the working with Git command line and Git in Visual Studio. You can find the previous blog post here. In previous blog post, we discussed how to use git rebase commands, the effects of same on the branching strategy and also rebasing on the same branch. In this post, we’ll discuss how to use git rebase inside Visual Studio.

Re-creating Problem Scenario

For starters, we have two branches named master and newQuickFix branch in Continue reading “Working with Git and Visual Studio – Use Git Rebase inside Visual Studio”

Working with Git and Visual Studio – Use git rebase with git command line

This blog post is part of in-depth blog series on the working with Git command line and Git in Visual Studio. You can find the previous blog post here. In previous blog post, we discussed what is git rebase, how it is different from git merge and when to use the rebase command. In this blog post, we’ll follow that up by using git rebase commands at git command line and understand it further.

Re-creating Problem Scenario

For starters, we have two branches named master and newQuickFix branch in our

Continue reading “Working with Git and Visual Studio – Use git rebase with git command line”