This is the 20th day of my participation in the August More Text Challenge

preface

Today we are going to talk about Git and GitHub. Despite their similar names, they are really two different things.

To put it simply, Git is a version management tool, which can better manage the code you write, while GitHub is a website, which contains a large number of open source projects, of course, you can also use GitHub to host our project code.

Here’s a quick look at these two things

The basic concept

  • The Repository:

Repositories are used to store project code, one repository for each project, and multiple open source projects have multiple repositories.

  • Star:

Collection items, convenient next time to view.

  • The Fork:

Copy clone project, exist independently

  • Pull request:

Ask someone to pull your repo

  • Watch:

Keep track of projects and receive notifications when they are updated

  • Issue: the problem

Found code bugs, but there is no current code, need to discuss.

* You can sign up for a Github account using your email address

GitHub

The warehouse home page

  1. Warehouse to create

  2. Warehouse management

  • New file new

  • Creating a new file

  • Delete this file

  • Upload a file

  • Warehouse file find file

  • Clone or Download

.

Open source project contribution process

  1. A new Issue

Submit usage questions or ideas

  1. Pull request

steps

  • The fork project
  • Modify the project code of your own repository
  • New Pull request
  • Wait until the authors are in sync

Git

Git Installation and Configuration

Before using Git, we need to install Git, Windows system Git installation package download address

Once the installation is complete, you are ready to use the command-line Git tool (which already has its own SSH client)

There is also a graphical Git project management tool

Go to “Git”->”Git Bash” in the Start menu

Git Workflow

  • Working Directory

Add edit modify etc

  • The staging area

The staging files are here, all together committed to the Git repository

  • Git Repository git repository

The final file is saved to the warehouse and becomes the new version, which is visible to others

The general working process is as follows:

  1. Clone the Git resource as the working directory
  2. Adds or modifies files on cloned resources
  3. If someone else makes changes, you can update the resource
  4. Review the changes before committing
  5. Commit changes
  6. After the changes are made, if errors are found, the commit can be withdrawn and modified and committed again

Git initialization and repository creation operations

  • Basic Information Settings

Git config –global user.name “Your name”

Git config –global user.email “[email protected]

Note: Change Settings on the Github repository home page to show who submitted the file

  • Initialize a new Git repository

1. Create a folder

Command :mkdir test (or right-click to create a test)

2. Initialize git in a file

Command: git init

3. Add it to the temporary storage area

Git add file name;

4. Submit files from staging area to warehouse

Git commit -m

(3) Modify warehouse files

1. Run the vi command to modify the file

2. Add the file name to the staging area with git add command

3. Run git commit -m ‘describe’ to commit the file from staging area to repository

* Other common commands

(4) Delete warehouse files

1. Delete files

Delete the file directly from the folder or run the rm -rf fileName command. Rm test. PHP Rm is the command to delete files in Linux. -r indicates to delete everything under this command, and f indicates to run the command without user confirmation

2. Delete files from Git

git rm test.php

3. Submit the operation

Git commit -m

Git status: to check the status

Ls: displays the directory

CD: next directory

Vi: For the improved version, enter the vi full-screen editing screen

Cat: View the contents of a file

Git config –list

GIt manages remote repositories

Git can operate remote repositories as well as local repositories

The purpose of using remote repository: backup and centralized management of shared code

Synchronize local repositories to git remote repositories

Git clone

Objective: To replicate the remote repository (github’s project) locally

Git Clone repository address

Synchronize local repositories to git remote repositories

git push

summary

1. Create a file

2. Add the file to the staging area git add filename

Git commit -m ‘description’

4. Add git push to remote repository

Github Pages builds the website

  1. Personal site

Access: https:// username.github. IO

Setting up steps:

(1) Create a personal site –> create a new repository (note: the repository name must be: username.github. IO)

(2) Create an index. HTML file under the repository.

Note:

  1. Github Pages only supports static web pages

  2. You can only have.html files in your repository

Project Pages Project site

Access: https:// username.github. IO/repository name

Setting up steps:

  1. Go to the project home page and click Settings

  2. On the Settings page, click on source, which was None, and make it the master branch,

That is, as a branch to deploy Github Pages, and click Save. The page will refresh and you will return to GitHub Pages and find an extra link. This is the url of your GitHub Pages. The website is https://username.github. IO/repository name