Git and GitHub Class Prepatory Steps
Git and GitHub Class Prepatory Steps
Hello Class,
Before we start with our Git class, we are trying to make sure that we will not encounter any
technical issues along the way. Our team, already requested access for all of us.
Please follow the steps below to get started with Git and GitHub. After doing all of the steps
below, I need you to reply to the group chat stating 'DONE' - 100% for example.
If you encounter any problems, please DM me (Mylene Arao-arao), so that we can fix try to fix
them together. Thank you.
- Select Public (this is a repository where everyone can access and download but they can't
modify it)
Note: Everyone can create a Private repository. You can change the visibility later
- Put a checkmark beside "Add a Read me file"
- Click "Create Repository"
You can check whether Git is installed and what version you are using by opening up a terminal
window in Linux or Mac, or a command prompt window in Windows, or gitbash, and typing the
following command: git --version.
If it is not under your credentials, you can proceed with Step number 5, otherwise, proceed to
Step 6.
- Commit is like a snapshot that we can restore later if necessary. We can revert at a certain
point in other words
$git commit -m "Message"
- Your message should be something meaningful. It should be short but powerful.
Sample Output:
mylene.araoarao:
$ git status
On branch main
Your branch is ahead of 'origin/main' by 2 commits.
(use "git push" to publish your local commits)
NICE TO KNOW:
OTHER WAYS OF CLONING A REPOSITORY FROM GITHUB
a. First Way To Clone a Git Repository
Collaborator Access
- GitHub gives collaborators access to a maximum of three members if the repository is Private,
whereas unlimited members for Public repositories.
- It will show in the notification of the collaborator that he or she is invited to be a collaborator of
your repository.
- The collaborator can now see your code.
- You can also delete the collaborator by clicking the delete icon under Settings > Manage
Access
Note: You can either use GitBash or Eclipse Git Perspective in pushing the code to your
Team's repository.
******
USING GIT BASH
1. Group Members will clone the repository of their leader. After cloning. Create your own
branch
$ git branch YourBranchName
$ git checkout YourBranchName
To add a single file to Git, we can use the add command like so:
$git add README.md
$git status
If we rerun the status command, we should see that the readme file is now tracked. (color
green)
- Execute the following command you just got from GitHub. (Make sure this is your repo URL)
We add a remote with the name origin in the above step. You can name this differently, but the
origin is the default and most common.
We need to run the following command to push to GitHub as we just set up.
Here we tell git to push to our origin remote on the master branch.
And if you now head over to GitHub, you should see your code and commit.
*******************************
FAQ
1. Unable to push GitHub in Eclipse. Error " Push to GitHub has encountered a problem"
Reason:
Github: fatal: Authentication failed Support for password was removed on August 13, 2021
Solution:
- Fix: Authorized Error
- Login to your GitHub Account.
- Go to Settings from your user icon,
- From the sidebar select Developer Settings
- Personal Access Tokens -> Personal access tokens (Classic)
- Generate a new Token, select repo option (others if applicable)
- Copy the Token and Save It
- Go to Eclipse Preferences -> General -> Security -> Secure Store -> Clear Password
Cache
- Now try to do a Git Pull, you will get a prompt to enter your username and password. Enter the
git username and the token just generated and - click log in.
2. How to Add GitHub SSH Key
- Open Git Bash
- Paste the text below, substituting in your GitHub email address.
ssh-keygen -t ed25519 -C "[email protected]"
- Type the file name where you want to save the key.
- Enter the paraphrase twice.
- Press Enter
- Take note of the path of the file where the key was saved.
- Go to the said path and open the key file that ends in '.pub'
- Copy the SSH key
- Open GitHub
- Click your profile icon at the top right.
- Click Settings
- Click SHS and GPG keys
- Click New SSH key
- Type your desired title.
- Paste the key inside the textbox labeled 'Key'
- Click 'Add SSH key'
- It should now show the new SSH or authentication key.