DEV Community

Cover image for How to properly set up Git on your computer!

How to properly set up Git on your computer!

Landon Patmore on January 24, 2018

Installing Git OSX Setup If you have never used Git on your computer, you most likely will not have it installed. Pull up yo...
Collapse
 
itsjzt profile image
Saurabh Sharma

I would highly recommend using Git Bash as it gives you information about the branch you are working on right in the terminal compared to command prompt which does not tell you any information, as well as you can use Linux commands.

Windows guys actually made a plugin for PowerShell which you can install with Install-Module posh-git -Scope CurrentUser that's it,

Collapse
 
landonpatmore profile image
Landon Patmore

Hi Saurabh,

I just looked at the plugin and it looks pretty awesome. But the issue I see is now is that even though the plugin can be installed for Powershell, you still need to install Git through the means I provided in the article. This now means the user has to install two things rather than one.

While it may be small, I personally would stay with Git Bash, especially for the Linux commands and so that I wouldn't have to install another thing on my system.

To each is their own, and I will take your comment and add it into the article, thanks for the feedback and another tool to use!

  • Landon
Collapse
 
bdwakefield profile image
Benjamin D Wakefield

So here is my thing; it isn't always about installing the fewest things or whatever. It is about having the tools to do the job in the way that works best for you; especially when those things don't add additional strife to others on your team.

If you are working on Windows -- you are going to benefit from using PowerShell. Especially if you spend some time to customize your profile (just like you would with your bashrc, etc)

If you are working primarily with Linux systems then it makes sense to stick with that. You have the Linux Subsystem for Windows that is pretty slick.

The only issue I take with the article (all very good information) is that it is implied that this is THE proper way to do it. That just isn't the case. There is more than one way to skin this cat; and when personal opinion comes into play (like it does with so many things about how you do work) it is not really possible to say "this way is the correct way".

Collapse
 
busches profile image
Scott Busche • Edited

I'd highly recommend cmder.net for Windows. It includes Linux commands, git, and more!

Thread Thread
 
itsjzt profile image
Saurabh Sharma

yeah, cmder is the coolest terminal available for windows along with hyper.is

Collapse
 
niketpathak89 profile image
Niket Pathak • Edited

Git bash is definitely worth it. You can also use a GIT Prompt to see the status of the git repo right there in your console. Setting up git prompt

Collapse
 
bdwakefield profile image
Benjamin D Wakefield

Came here to say this; been using this with git from PowerShell and it is pretty much the bees knees.

Collapse
 
dschep profile image
Daniel Schep

One more bit I consider critical in a proper git setup:

git config --global core.excludesfile '~/.gitignore'
# on a mac:
echo .DS_Store >> ~/.gitignore
# If you use vim
echo '.*.sw[po]' >> ~/.gitignore
# And any other files that should never be checked into git in ANY repo
Collapse
 
landonpatmore profile image
Landon Patmore

Hi Daniel,

I wish I could give you a cookie, I forgot about global .gitignores myself.

I will add this in!

Thanks!

Collapse
 
dschep profile image
Daniel Schep

Hah, excellent!

Collapse
 
moopet profile image
Ben Sinclair • Edited

Nice. A couple of assumptions I'd highlight though - the linux instructions are Debian specific, and git doesn't require a github account (this is important because a lot of newbies think they're some kind of official part of git). I know your post has github as a tag, but the title implies it's a general git tutorial.

Collapse
 
landonpatmore profile image
Landon Patmore

Hi Ben,

I wrote this up for a class and completely forgot about changing it to be more broad. When I’m back from class, I will change it. Thanks!

Collapse
 
jebarsallo profile image
jebarsallo

Hi, Landon.

First, the article is pretty good. Kudos for that. :)

The only (minor) thing I can comment about is your comparison of PowerShell as being the same as Command Prompt. They're not. In fact, PowerShell is a completely different shell environment. It's simply the shell that Windows should've always had.

Keep the good work!

Jorge

Collapse
 
landonpatmore profile image
Landon Patmore

Hi Jebarsallo,

Thanks for the help! I am not a windows user, so I don’t know this! When I get near my computer again, I will fix it!

Thanks!

Collapse
 
daemoen profile image
Marc Mercer

If you're going to install on windows, see if there is already a package for it via chocolatey.org. Chocolatey is much more useful for managing installations, and the more people use it, the more things are kept in sync.

Collapse
 
landonpatmore profile image
Landon Patmore

I like it, just like homebrew for OSX.

Collapse
 
marengunnars profile image
Maren Gunnarsdóttir

Thanks for an easy to follow tutorial!

At step 5 in "Generating a SSH Key" when I write "ssh-add -K ~/.ssh/id_rsa" I get the error "ssh-add: unknown option --K", do you know how to deal with this?

I'm new to git and can't find anything when searching for the error.
I hope you can help!

Collapse
 
landonpatmore profile image
Landon Patmore

Hi Maren,

As the error says, you wrote “—K” instead of “-K”. If it throws you an error even with that, try “-k”.

Hope it helps.

  • Landon
Collapse
 
marengunnars profile image
Maren Gunnarsdóttir

Hi Landon,

That was exactly the help I needed!
My problem is now solved :)

Thank you so much!!

Collapse
 
netbzz profile image
NetBzz

I think you need a lower case 'k' as the parameter.

ssh-add -K ~/.ssh/id_rsa
unknown option -- K
-k Load only keys and not certificates.

Collapse
 
landonpatmore profile image
Landon Patmore

Hi NetBzz,

I took that directly from GitHub’s guide on how to create SSH keys.

It works perfect for me!

Collapse
 
marsavela profile image
Sergiu Marsavela

It works because you're using macOS. On any other Linux distro that uses OpenSSH will ask for the lowercase 'k'.

Collapse
 
annarankin profile image
Anna Rankin

Awesome write-up!! I wish I'd had all this written out when I first got started. 💯

Collapse
 
johand profile image
Johan

Another tool for git is tig

Collapse
 
kip13 profile image
kip

If you work with GitHub I think that hub is really useful

Collapse
 
madalinignisca profile image
Madalin Ignisca

U should not make the assumption that everybody in the Linux ecosystem is using Ubuntu/Debian.