Week 1 Intro to GitHub
Sign up the GitHub Account¶
- Create a GitHub Account (highly recommend use University email)
- Include a personal email as back-up email
- A domain name is a unique URL address that points users to your website.
- GitHub Pages will provide us a domain name at yourusername.github.io.
Repository in GitHub¶
A repository (or 'repo' for short) on GitHub is essentially a storage space where your project's files, including code, documentation, and other resources, are stored.
More detail about Repository find in GitHub Docs
Customize profile¶
Create new repo¶
Click + on the top right corner
Make sure your repo name is the same as your user name
Set is as Public and Select 'Add a README file'
GitHub will display your profile README on your profile page if all of the following are true.
- You've created a repository with a name that matches your GitHub username.
- The repository is public.
- The repository contains a file named README.md in its root.
- The README.md file contains any content.
Small Tricks to polish profile¶
Emoji¶
Copy emojis and paste them in file
Static Bage¶
'any_text', 'you_like' and 'blue' are user-defined Modify Static Bage per you needed
For example is defined as https://img.shields.io/badge/My-LinkedIn-blue
Format that create a LinkedIn badge that connect to your associated account
- [![Alt text](link of badge)](link to content)
Copy below code to file then you will see a badge tha connect to you relevent account
Dynamic badges¶
Dynamic badges can show metrics for your repo or project.
Hash tag control the font size¶
Insert Hyperlink for words or sentence¶
_ for bold text¶
Get good design from others README file¶
If you are interested in others design about README file, you can folk repository to edit it.
Top Tabs¶
- Issues: Report issue about this repo (e.g., code error)
- Discussions: ask question or provide comments for the repo (You can hide or show disscussion through change setting in Settings)
- You can insert image, code in the Discussio
- Action: show change in the repo
- Insights: Metrics (e.g., how many people visit your ) about your repo; Referrring sites; Popular content
Install VS code¶
Git¶
1. Install¶
Go to the Git website to download the installer for your operation system
2. Set up account name and email address¶
Set up your account name and email address in Git
The account name can be anyname, Git doesn't care. it just need to know to whom to credit commits and future projects.
git config --global user.name "Double"
- More information pelease find here Setting your username in Git
Use the sign-up email of your GitHub Account
git config --global user.email "GitHub_Sign_Up_EmailL"
- More information please find here Setting your commit email address
Check your account name and email
git config --global --list
3. Connect remote repository to local repository¶
when you first time use Git, it requres you to log in your GitHub account
3.1 Clone a remote repository to local computer¶
git clone <repository_url>
3.2 Make some change to local repository, then update the remote pository based on Step 1 - 3.¶
- To add files to the staging area, run the following command:
git add .
- To commit the changes, run the following command. Repalce message with your comment to this commit
git commit -m 'message'
- Push the change from local repository to remote repository
git push
3.3 Update local repository based on remote repository¶
git pull
4. Update Github in VS Code¶
You can use Source Control in VS Code to update content in Github
5. Troubleshooting¶
5.1 Token issue
Error message: Remote: invalid username or password fatal: Authentication failed
Solution:
- click your profile photo, then click Settings.
- Navigate to Developer settings > Personal access tokens > Tokens (classic) > Generate new token > Generate new token classic
- In the Note field, assign a name to this token
- In the Expiration field, set an expiration date for this token. In this example, I set it for 90 days
- From the scopes menu, select all options. This will allow you to edit your repo
- Click Generate token at the bottom of the page
- Copy the generated token as it won't be shown again and temporatily same the token before closing the window
- Changing a remote repository's URL
Replace
Replace USERNAME with your GitHub username
Replace REPO with the name of your GitHub Repo
git remote set-url origin git remote set-url origin https://<your-token>@github.com/USERNAME/REPO.git
Special thanks to Tanner Honnef for contributing this solution!