Basic use of git and github use warehouse to pull and submit

git use

1. Basic use

1. Global configuration is required for first use:

Configure the user name and email.
Check whether the user name and email are successfully configured.
The user name and email address are set globally, and all Git warehouse submissions will use this username and email address.
Insert picture description here

2. Create a test folder

The default location is on the desktop (the command operation is the same as liunx)
mkdir test_git
Insert picture description here

3. Enter the file initialization warehouse

git init
Insert picture description here
sets this hidden project to see .git
Insert picture description here
or ll -a to view hidden files
Insert picture description here
git status, query the status of all files in the current workspace

On branch master: The current branch master
No commits yet:
nothing to commit (create/copy files and use “git add” to track): No commit is currently being made, you can create or copy files and use "git add" Command to track
Insert picture description here

Add files to the cache

Syntax 1: git add file name
Syntax 2: git add file 1 file name 2 file name 3…
Syntax 3: git add. (There is a point) [add the current directory to the cache]

Add the readme.txt file to the cache area
git add readme.txt
error occurred fatal: pathspec'readme.txt' did not match any files
Insert picture description here
solution
touch create file
Insert picture description here

Use git status again to view the status of the file
Insert picture description here

The git commit -m "comment content" command submits the files in the cache area to the repository
Insert picture description here

2. Version rollback

1. First follow the above steps to add and submit test.py

Insert picture description here

2. Two ways to view the version change log command

The yellow part is the version number, followed by the comment content.
Generally use the second git log --pretty=oneline
Insert picture description here
version rollback: git reset --hard version number
git reset --hard 06e35cc1f9d4228ab4a7a24bf266cf36d4d32583
Insert picture description here

Before
Insert picture description here
rollback After rollback
Insert picture description here

Go back to the latest version
1. Git reflog View historical version
2. Find the corresponding version number
3. Git reset --hard 0a0795b Go back to the latest version
Insert picture description here

github use

1. The creation of remote warehouse

1. Interface translation

Insert picture description here
Insert picture description here

2. Warehouse naming and setting

Insert picture description here

2. Clone the project

1. Create an empty directory first

Insert picture description here

2. Use git clone to clone the online warehouse to the local

Insert picture description here
git clone https://github.com/Theshy0000/python_api.git
Insert picture description here

warning: You appear to have cloned an empty repository.
Prompt that a new repository has been cloned (don’t care if it is empty). The
clone is successful
Insert picture description here

2. Submit documents to the online warehouse

1. Submit the content of the workspace to the github remote warehouse

First move the target file to the python_api directory
Insert picture description here

2. Perform file submission operations (cache area, local warehouse) [don't forget]

View current file working path
Submit to cache area
Cache area to local warehouse
Insert picture description here

3. Submit to online operation (requires token)

git push origin master
Insert picture description here

4. Get the token

To Github Get your own Personal Access Token, the home page to enter the set
Insert picture description here
point here
Insert picture description here
Click here to
Insert picture description here
point this generates a new token
Insert picture description here
password
Insert picture description here
after entering the password to this
Insert picture description here
translation at the top of the screen
Insert picture description here
set up point above the
Insert picture description here
then net blown up
Insert picture description here
do not panic, points this look , Go back, the next step is coming, it should be fine
Insert picture description here

Insert picture description here

5. Fill in the token and click sign in

Insert picture description here
Insert picture description here

6. Check if the upload is successful

success
Insert picture description here

3. Pull online warehouse file operation

1. Online warehouse creation file

Insert picture description here
File name and file content, click Create.
Insert picture description here
Created successfully
Insert picture description here

2. Pull online warehouse files to local

An
error occurred during git pull pull down. It
Insert picture description here
would be fine to pull it again,
Insert picture description here
but test.py did not pull down. Is there any advice from the boss?

Error one

Insert picture description here

Error two

Insert picture description here

Reference document https://www.cnblogs.com/gian-t87/p/14513056.html

Guess you like

Origin blog.csdn.net/aaaaaaaaanjjj/article/details/115182796