Before you can even start using Git on your computer, you have to be able to access Terminal. That is where Git commands will take place.
To open up Terminal on Mac, run the following shortcut on your keyboard followed by hitting the return key:
Command key + Space key
And a big input field with the placeholder text "Spotlight Search" will appear in the top left corner of your computer screen.
Next, inside that input field, type Terminal.
Then click on the highlighted selection, and a window instance of Terminal will appear. Now you are ready to use it.
One thing to note is that whenever you initially open up Terminal, it opens up in your computer's Home directory, which is represented by the tilde ~ symbol in your Terminal window instance.
First you have to sign up for a Github account before you can take advantage of all it has to offer!
Please visit github.com to sign up.
Git is already installed on the School computers, but since the course is online now, you will have to install it on your own computers. I have
included a couple of links about to how to install Git for those of you that might not have it installed at
home.
If you are on a Mac, to check whether you have Git installed on your computer, type the
following
command
in Terminal and then hit the return key:
git --version
If you have Git installed, something like the following
should print out to the
Terminal Console:
git version 2.x.x
On macOS systems you should have Git installed. Homebrew is great for installing packages
you need on your MacOS.
But to make your life easier and the install go more quickly, don't install Git with Homebrew. Leave that for another day. Since by now you have installed Xcode, Git comes as part of the package.
Whether you are configuring your email for Github at School or at home, this step remains the same.
git config --global user.name "Emma Paris"
$ git config --global user.email "eparis@atlassian.com"
Make sure to replace Emma's name with yours, and Emma's email with yours when you do this step!
Note: If you want to do anything on Github
outside of your own
repositories
and don't want to encounter
any problems, DON'T keep your email private there. Just make sure then
that you use an
email you don't mind making
public. You should take advantage of everything that Github has to offer,
including
creating issues on
the
repositories of tools you love to use!
Before August 13, 2021, it used to be that you could authenticate yourself using your Github username and password via the Command Line on your local machine before pushing local repository changes to Github. This was called authenticating with HTTPS. We still authenticate with HTTPS, but just inputting our username and password to do so is not enough.
Now, if you want to authenticate on Github using HTTPS, you first have to create a Personal Access Token on Github.
Personal Access Tokens have replaced using usernames and passwords for authentication to GitHub when using the GitHub API or the Command Line.
As a security measure, GitHub automatically removes personal access tokens that haven't been used in a year. To provide additional security, Github highly recommends adding an expiration to your personal access tokens.
A token with no assigned scopes can only access public information. For more information on scopes, see "Available scopes".
First verify your email address, IF it has not been verified yet. To learn about how to verify your email address with Github, please visit Verifying your email address for Github.
In the right hand corner of any page on Github, click on your profile photo/avatar, and then select "Settings" from the dropdown that appears.
To access Github's documentation on creating a personal access token, you can visit Creating a personal access token.
Once you have entered your account "Settings" area, in the left hand side bar, you will see a tab called "Developer Settings".
Click on "Developer Settings" to enter it.
To access Github's documentation on creating a personal access token, you can visit Creating a personal access token.
When you click on the "Developer Settings" tab, you are taken to the GitHub Apps area.
In the left hand side bar, you will see a tab called "Personal access tokens". Click on that.
To access Github's documentation on creating a personal access token, you can visit Creating a personal access token.
After you have clicked on the "Personal access tokens" tab, you are taken to the "Personal access tokens" area.
To the right of the "Personal access tokens" heading, you will see a button with the text "Generate new token". Click on that.
To access Github's documentation on creating a personal access token, you can visit Creating a personal access token.
After you have clicked on the "Generate new token" button, an input field will appear with the title "Note". Below the input field is the text "What's this token for?". Create a descriptive name for your token so that you will remember why you created it and what you are primarily using it for.
To access Github's documentation on creating a personal access token, you can visit Creating a personal access token.
As mentioned earlier, Github highly recommends selecting an expiration for your personal access token for security purposes. To give your personal access token an expiration, select the Expiration dropdown menu, click on a default selection, or use the calendar picker.
To access Github's documentation on creating a personal access token, you can visit Creating a personal access token.
As mentioned earlier, if you do not explicitly set any scopes for your personal access token, you would only be able to use it to access public information/repositories on Github. That includes your own repositories as well.
For the purposes of complete inclusion, select ALL available scopes to grant your token.
To access Github's documentation on creating a personal access token, you can visit Creating a personal access token.
All the previous steps are set up steps needed before you actually generate your new token.
Once you have completed selecting the scopes you want to apply to your new personal access token, you can finally click on the green "Generate token" button.
To access Github's documentation on creating a personal access token, you can visit Creating a personal access token.
Now that you have set up and generated your new personal access token, you have to make sure that you are set up for it on Github.
When you create a repository on Github, make sure that the following has been selected within your green "Code" button in the "home page" of your repository.
In other words, make sure that HTTPS has been selected. Then, by default, all the other repositories you subsequently create will also have "HTTPS" selected there.
If you are using VS Code's Integrated Terminal, and you will be for this course, you have to make sure that VS Code recognizes your personal access token as well. Otherwise, you will local repository commits to your remote repositories to Github. In order to make that happen, you have to make sure that you have added the VS Code Github extension by KnisterPeter. It is among the extensions listed in the VS Code Installation and Set Up slide deck.
Once you have created a personal access token on Github, and you have added the Github extension in VS Code, you are ready to add Github authentication in VS Code using your personal access token.
First, open up the VS Code command palette by using the following keyboard shortcut:
Shift key + Command key + P key
And the following will appear at the top of the active VS Code window:
Next, as shown in the screen shot above, start typing the words personal access token, and Github: Set Set Personal Access Token will appear below the input field.
Next, copy and paste your personal access token into the input field, and then hit the return key on your keyboard. And that is it! Now you can start pushing your local repository commits to Github to your heart's content!
Now we are ready to git it on with Git on Github!