GIT basic use and learning

Install git's visual tool sourceTree (git GUI is not suitable for learning git, for better learning, use Git bash) to
install git, you can also use the command line directly

Commands used

System commands that may be used

vim (file name) Open the file
esc: wq enter exit and save and return (where wq means save and exit, can be changed to q, that is, exit directly, there are other exit methods for us to choose to understand and summarize)
cd ~: back to the user Initial directory
ll: view files in the current directory
pwd: display the current working area
ls -a //Display all files and folders in the current directory, including hidden. and... etc.
ls //Display files and folders that are not hidden
( ls also has -l parameter (you can view detailed information such as ls -l, ls -al))

cat: The cat command is a text output command, usually used to view the content of a file;
cat has three main functions:
1. Display the entire file at once. $ cat filename
2. Create a file from the keyboard. $ cat> filename
can only create new files, not edit existing files.
3. Combine several files into one file. $cat file1 file2> file
(The specific cat parameters are not explained in detail, please check by yourself)

git operation command

git init initialize the warehouse
git add (modified file)
git commit can be submitted to the workspace (you can add -m "(description information)" to add description information)
git push to promote the remote warehouse (add it if you use the remote warehouse for the first time上-u origin master)

Connect to remote warehouse (github)

1. Connect to local git

Enter github, point to the user in the upper right corner, –>settings–>SSH and GPGkeys–>new SSH key,
enter the title of the key, leave the key blank for now, use the client to generate the key and copy it over. (Enter the command line at this time)
Enter the command (generate key) (Note: the mailbox here is the mailbox used for registering github)

ssh-keygen -t rsa -C "(github email address)"
Insert picture description here
does not use a password, press Enter all the way, (if there is no coverage, choose y). The key is generated and placed in .ssh/. The
public key and private key are stored in .ssh/. The next thing to do is to get the public key and copy it to the key in github.

Insert picture description here
Get the public key and copy the key to github, and add the key. ok, complete, if you want to check whether the local and remote connections are good,
use the command
ssh -T [email protected] for the
first time, there may be warnning, and then continue to repeat the command ssh -T [email protected]
until Hi...
Insert picture description here

2. Create a remote warehouse

First enter github, click the plus sign in the upper right corner, —>new repository -->After creating the repository, enter the command line and
enter the local workspace.
The important command is to connect to the remote repository.
Insert picture description here
Insert picture description here
Follow these github commands to create README.md to promote github
Insert picture description here
remote creation success! ! README.md was successfully pushed, and you can see your results in your new Github repository

Guess you like

Origin blog.csdn.net/weixin_43722571/article/details/99672372