Git

Git – Refusing to merge unrelated histories

I ran into the following Git errors today when adding a new project to an existing Git repo.

$ git pull
fatal: refusing to merge unrelated histories

The initial steps I took to add my project the existing repo were the following.

  • git init
  • git add .
  • git commit – m “comment”
  • git remote add origin <repo url>
  • git remote -v
  • git push origin master

For what ever reason I was forced to do a reset –hard.  After this, I tried a pull and encountered the unrelated histories error. (ODD)

Solution: git pull –allow-unrelated-histories

github-octocat

Git Command Helper for TFS Users

The majority of the projects I have worked on in the past have used either TFS (TFVC) or Git.  For the projects that have used Git, I’ve noticed that for the people unfamiliar with Git, there can be some hesitation because of the unknowns.

So in this blog post I will simply try to align the standard TFS commands with the corresponding Git commands.  Hopefully this will help out any beginner Git users who are already familiar with TFS.

  • TFS (Get Latest) – Git (Clone and Pull)
    • Git Clone makes a Git repository copy from a remote source.
    • Pull gets files from the remote repo and merges them to the local repo.
  • TFS (Add) – Git (Add)
    • Remember, with Git you are working with a local repository, so the “git add” command will add the file(s) to your local repo for tracking purposes.
  • TFS (Check-in) – Git (Commit) (Push)
    • The “git commit” command will commit your changes to your local repo.
    • The “git push” command will push the changes to the remote repo.
  • TFS (Check-out)  – Git (-)
    • Kind of like how you can setup TFS to auto check-out a file, Git automatically recognizes changes to tracks files
  • TFS (Branch) – Git (Branch)
    • The “git branch” command will create a branch as needed.
  • TFS (Label) – Git (Tag)
    • The “git tag” command will tag\label a Commit.
  • TFS (Shelve) – Git (Stash)
    • The “git stash” command will store\save\stash\shelve your changes.  Somewhat similar to the TFS shelve-set feature
  • TFS (Merge) – Git (Merge)
    • The “git merge” command merges changes from 1 branch to another similar to TFS and push to local repo.

I am by no means a Git expert, but hopefully this blog will help out any TFS guru’s uneasy about working with Git.

github-octocat

TortoiseGit – Key Generator

Here is a little gotcha that I have encountered before.  When creating public\private keys for use with Git and TortoiseGit, I seem to have no problem using PuttyGen.  (How To Link)

However, when I use SSH-KeyGen, I seem to encounter the following error while connecting to Git.

  • Couldn’t load this key (OpenSSH SSH-2 private key)

So here is the deal.  My install of TortoiseGit uses Pageant to store private key for use.  This program only really recognizes private keys in the .ppk format, which is the Putty format.

So what you can do with the KeyGen private key is, convert it to .ppk using PuttyGen.  Its pretty easy to do, just click the Load button from PuttyGen, select your file, enter your phrase, and then save the file (.ppk) back to disk.  Now update Tortoise (remote) to use this new .ppk file.

tortoise

Starting my blog…..

Starting up another blog.  My previous blog was on blogspot.com and ran for about 7 years.  Lots of good stuff, but time for a change, so I decided to try wordpress.com

Some of the DevOps topics and tools I will be blogging about are.

  • DevOps
  • ELK
  • Docker
  • AWS
  • Gradle
  • Ant
  • Maven
  • Ansible
  • TFS
  • Git\GitHub
  • Jenkins
  • Java
  • Spring Boot
  • Scrum
  • Monitoring
  • etc…..