[Git study notes] Basic use of git | gitee | gitignore file writing

Git Tutorial Notes

The tutorial here is the git course that I met Kuangshen at station b . The link to his full version of notes is as follows
https://mp.weixin.qq.com/s/Bf7uVhGiu47uOELjmC5uXQ
The following are the notes I took down by myself, sorting out and recording some summaries and knowledge points that I think I will read often. Friends who like it can like it and collect it.

install git

git official website download is slow, you can go to Taobao mirror to download http://npm.taobao.org/mirrors/git-for-windows/

image-20221031152612080

Remember to clean up the environment variables for anti-installation, and install the others without thinking.

image-20221031153619684

Git Bash : Unix and Linux style command line, most used and recommended

Git CMD : Windows-style command line

Git GUI : Git with a graphical interface, not recommended for beginners, try to be familiar with common commands first

Linux basic commands

  1. cd : change directory.
  2. cd . . Go back to the previous directory, directly cd into the default directory
  3. pwd : Display the current directory path.
  4. ls(ll): All the files in the current directory are listed, but the content listed in ll (two ll) is more detailed.
  5. touch : Create a new file such as touch index.js and a new index.js file will be created in the current directory.
  6. rm: Delete a file, rm index.js will delete the index.js file.
  7. mkdir: Create a new directory, that is, create a new folder.
  8. rm -r : delete a folder, rm -r src delete src directory
  9. mv moves the file, mv index.html src index.html is the file we want to move, src is the target folder, of course, in this way, you must ensure that the file and the target folder are in the same directory.
  10. reset Reinitializes the terminal/clears the screen.
  11. clear clears the screen.
  12. history View command history.
  13. help help.
  14. exit Exit.
  15. #Represents comments
rm -rf / 切勿在Linux中尝试!删除电脑中全部文件!

gitignore ignore files

  1. Empty lines in the ignore file or lines beginning with a pound sign (#) will be ignored.
  2. Linux wildcards can be used. For example: an asterisk (*) represents any number of characters, a question mark (?) represents a character, square brackets ([abc]) represent an optional character range, braces ({string1,string2,…}) represent an optional string, etc.
  3. If there is an exclamation point (!) at the beginning of the name, it indicates an exception to the rule and will not be ignored.
  4. If the name is preceded by a path separator (/), it means that the files to be ignored are in this directory, and the files in subdirectories are not ignored.
  5. If there is a path separator (/) at the end of the name, it means that the subdirectory of this name under this directory is to be ignored, not the file (the default file or directory is ignored).
#为注释
*.txt        #忽略所有 .txt结尾的文件,这样的话上传就不会被选中!
!lib.txt     #但lib.txt除外
/temp       #仅忽略项目根目录下的TODO文件,不包括其它目录temp
build/       #忽略build/目录下的所有文件
doc/*.txt    #会忽略 doc/notes.txt 但不包括 doc/server/arch.txt

Git project construction

Create a working directory and common commands

The working directory (WorkSpace) is generally the folder you want Git to help you manage. It can be the directory of your project or an empty directory. It is recommended not to have Chinese.

For daily use, just remember the following 6 commands:

[External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture and upload it directly (img-GGqEVmNi-1667226632070)(https://gitee.com/dengxiaoyang/blogimage/raw/master/img/640)]

Build a local warehouse

There are two ways to create a local warehouse: one is to create a brand new warehouse, and the other is to clone a remote warehouse.

1. To create a new warehouse, you need to use the root directory of the project managed by GIT to execute:

# 在当前目录新建一个Git代码库
$ git init

2. After execution, you can see that there is only one more .git directory in the project directory, and all the information about the version is in this directory.

Clone the remote repository

1. Another way is to clone the remote directory, because the warehouse on the remote server is completely mirrored to the local!

# 克隆一个项目和它的整个代码历史(版本信息)
$ git clone [url]  # https://gitee.com/...

2. Go to gitee or github to clone a test!

git file operation

#查看指定文件状态
git status [filename]
#查看所有文件状态
git status
# 添加所有文件到暂存区
git add .                  
# 提交暂存区中的内容到本地仓库 -m 提交信息
git commit -m "消息内容"    

Use code cloud

GitHub has a wall and is relatively slow. In China, we generally use gitee. Sometimes the company builds its own gitlab server

  • Set the local machine to bind the SSH public key to realize password-free login!

  • Password-free login, this step is very important, Code Cloud is a remote warehouse, we usually work in a local warehouse!

  • generate public key

  • ssh-keygen -t rsa

    image-20221031160307260

    Just add the public key information public key to the code cloud account!

image-20221031160613672

Use code cloud to create your own warehouse

image-20221031161320916

image-20221031163320361

  • Add to the staging area git add .
  • commit Submit git commit -m ''
  • push to the remote warehouse git push

Guess you like

Origin blog.csdn.net/dxy1128/article/details/127624865