To work with this tutorial, you’re going to need a few things:
Git, of course. Install this by going to the git homepage, git-scm.com.
A GitHub account. Create an account by going to github.com.
A text editor. Try Visual Studio Code (VS Code) or Sublime Text (both of which are multiplatform).
Configure them to be your default git editors by following the instructions on this page. Note: programs like Microsoft Word or TextEdit are not valid text editors here because they don’t produce plain text files, but rather more elaborate file formats that include text formatting information.
A graphical git client or browser. This lets you visualize your git history more easily, and understand the concepts behind git better. For a full list of clients, see here. On Mac, I recommend Git Tower, though it’s not free. The cross-platform SourceTree is free and available on Windows and Mac. On Linux, try gitg or gitk.
Install Git on Windows:
git --version
in the git bash window. You will see the installed git version like this: git version 2.33.0.Install Git on Mac OS X:
git --version
in the terminal. You will see installed git version like this: git version 2.33.0.Install Git on Linux:
sudo apt install git-all
or sudo yum install git
.git --version
in the terminal. You will see the installed git version like this: git version 2.33.0.Open the GitHub link and sign-up using your email address.
Remember your email id and your unique GitHub username; we will be using them in git configuration.
You also need to configure git so that it knows your full name and email address. Fire up a console/terminal, and type:
DO NOT copy the $
for the command.
Note that you need to replace “Your name” with your own information.
Please use the same email address you used for your GitHub account.
For a more user-friendly text editor, we recommend Visual Studio Code and you can associate it with Git by typing the following command in your terminal/git bash window:
The following command also lets you see a rudimentary graphic of your history without needing a GUI git client:
Then you can get a nice history (when you have several commits later) within your terminal by typing:
Now our git configuration is completed and we are ready to work with git. However, each time we want to push (upload) files to GitHub, we have to associate the local machine with our GitHub account.
Setting up SSH key helps with authentication every time we want to push local commits to the web client GitHub. Please follow the instructions here to create ssh-key and adding it to your GitHub account. We have briefly outlined the commands needed for this step below, and please refer to the link above for more detailed explanations.
Press Enter three times (if you prefer to have another passphrase, type it twice).
Copy the SSH key by printing it and copy the output of the command:
Go to your GitHub Settings and click New SSH key
. Name your key and paste it in the Key
field.
Verify that the fingerprint in the message you see matches the following message, then type yes
:
Hi username (Your GitHub username)! You've successfully authenticated, but GitHub does not
provide shell access.
When typing a passphrase, it might seem that the keyboard isn’t working.
However, this is just a security feature (similar to the *
s you might see
when typing a password on the web). Just go ahead and type the passphrase,
then repeat it as requested.
For Windows users: Windows does not have an ssh agent running in the background by default. If you see the error:
you will need to use this command to start the ssh-agent:
(Be careful to use the proper backtick symbol, usually just above the “Tab” key on most keyboards; NOT the single quote/apostrophe character.)
Then type:
(You might need to change the filename from id_rsa
to whatever you used.)
See this StackOverflow answer for more
info.
You need to keep the window on which you launched the ssh-agent open.
Whew! That’s quite a lot of stuff! But I hope by the end of the tutorial you’ll find it all useful and worth getting! (Plus: free stuff!)