Git
Last updated
Was this helpful?
Last updated
Was this helpful?
Git installed via brew brew install git
And which git
should output /opt/homebrew/bin/git
.
Copy .gitconfig
file as described in to your home directory. i.e., ~/.gitconfig
Next, we'll define your Git user (should be the same name and email you use for GitHub):
Also copy .gitattributes
and .gitignore
files as described in to your home's my
directory. i.e., ~/my
Customize your .gitignore
by visiting and fill it what you need.
Why do you want this ?
Because Git will see diffs between files shared between Linux and Windows due to differences in line ending handling ( Windows uses CR and Unix LF)
TL;DR, Using git config core.autocrlf true
can help, but not on a multi-developers(Windows and MacOS) projects. This setting has to be the same on each developer machine, and that's not always the case.
Global settings for line endings
Set core.autocrlf
to input on MacOS
Set core.autocrlf
to true on Windows
Set a global to your home directory, as described in .
Pick a platform specific .gitattributes
from and .gitignore
from , add them to your project root.
Explore Web project template and .
If you have any binary files in the repository that:
are not correctly marked as binary in gitattributes
, and
happen to contain both CRLFs and LFs files,
This Gist normalizes repo by forcing everything to use Unix style.
After creating a new repo on GitHub, clone it using:
- if you had initialized with a README.
If you did not, follow the instructions in the section below.
If you are setting up a new repo, add at least one file and commit first. Then, configure the remote and push to GitHub by running:
First check for existing SSH keys on your computer by running:
Check the directory listing to see if you have files named either id_rsa.pub
or id_dsa.pub
. If you don't have either of those files then read on, otherwise skip the next section.
If you don't have an SSH key you need to generate one. To do that you need to run the commands below, and make sure to substitute the placeholder with your email. The default settings are preferred, so when you're asked to enter a file in which to save the key, just press Enter to continue.
Run the following commands to add your SSH key to the ssh-agent
.
If you're running macOS Sierra 10.12.2 or later, you will need to modify your ~/.ssh/config
file to automatically load keys into the ssh-agent and store passphrases in your keychain:
No matter what operating system version you run you need to run this command to complete this step:
The last step is to let GitHub know about your SSH key so GitHub can recognize you. Run this command to copy your key to your clipboard:
We are now ready to use SSH with GitHub!
After creating a new repo on GitHub, clone it using
- if you had initialized with a README.
If you did not, follow the instructions in the section below.
If you are setting up a new repo, add at least one file and commit first. Then, configure the remote and push to GitHub by running:
Then follow the instructions (echoed on ) to convert the repository to contain only LF line-endings
These instructions are from .
These instructions are for those who wish to use SSH and not HTTPS, and are from .
Then go to GitHub and . Paste your key in the "Key" text-box and pick a name that represents the computer you're currently using.