Git squash multiple commits into one

If you ever have a scenario where you have to make a lot of changes to a branch but commit regularly so you can go back during this process if something fails BUT when you are done as a whole none of those commits actually matter except the last one (historically it will be off no use to see what was changing between revisions) you can do this in git:

Note: Before you do this all your changes need to have been committed, make sure you have nothing staged.

git reset –soft <sha_of_initial_commit>
git commit -a –amend -m “commit message”

Update cloned repo with source

If like me you have a lot a cloned git repos but need to update them  with the original repo then this post is for you. With git it is very easy to do this. From within the clone run the following git commands:

git remote add upstream <original repo url>
git fetch upstream
git pull upstream <target branch, usually master>

Git squash multiple commits into one

If you ever have a scenario where you have to make a lot of changes to a branch but commit regularly so you can go back during this process if something fails BUT when you are done as a whole none of those commits actually matter except the last one (historically it will be off no use to see what was changing between revisions) you can do this in git:

Note: Before you do this all your changes need to have been committed, make sure you have nothing staged.

git reset –soft <sha_of_initial_commit>
git commit -a –amend -m “commit message”

Git Extensions Session #6 – Release notes generator

In this post I will show you how to generate release notes between two commit hashes, branch names or tags using git extensions.

From the main menu locate plugins and select the release notes generator plugin. You will see a dialog as shown in the screenshot below. In the screenshot I show how I have  created release notes between two release tags of the Telerik JustDecompile Engine together with the result release notes.

release notes.png

Git Extensions Session #5 – Statistics

As promised in an earlier post on the git extensions Impact Graph plugin I was to cover a similar plugin, the statistics plugin. This plugin can provide very interesting information about a project.

On the main menu locate plugins and select the statistics plugin. You will be presented with a dialog reviewed in the screenshots below. You will be provided with the following views (I particularly like the last one):

  • Commits per contributor
  • Lines of code per language
  • Line of code per type
  • Lines of testcode

1.png

 

Git Extensions Session #4 – Impact graph

If out of interest (please not for any other reason) you want to see in terms of commits and code lines changed how much you impact a project you can with git extensions.

On the main menu locate plugins and select a plugin called impact graph. You will see as screen as below with each color representing a user. The graph will show you how many commits each made overall and the timeline.

impact graph.png

Just so its out there, this is really not a metric for a persons performance or even impact as the name suggests. You can get a different view of similar information and more using the plugin Statistics covered in a later post.

If you simply want to see commits per user the fastest way is Tools -> Commits per user.

Git Extensions Session #3 – Git large files

Having issues with large pulls/fetches and not sure why. Well there could be a number of reasons such as committing dlls that could be on nuget or files that can be generated. Not to get into why really but git extensions can help you find out which files are contributing to here.

On the main menu select Plugins, then select the plugin named Find large files. Let this plugin run, it may take a while. The results will have information such as file paths and sizes. You can sort by any field of interest and can optionally delete the files (be careful). A quick research will surely provide you with some interesting solutions as to how to avoid checking in certain files.

large files.png