[git] Some basic operations of git

One.git download

Git download address: https://git-scm.com/downloads

Two. git initial operation

1. Generate public key

ssh-keygen -t rsa -C "[email protected]"

Then generate the file locally, the file path

windows:C:\Users\用户名\.ssh
linux:cd ~ 进入主目录

insert image description here
id_rsa.pub is the public key, copy and paste
insert image description here

2. Modify the global username and email address:

git config --global user.name  "username"     
git config --global user.email "[email protected]" 

3. The local warehouse is associated with the remote warehouse

git remote add origin ssh://[email protected]/weiyuting/shortLink.git

4. Local initialization

git init

5. Add all files on the project to the local warehouse

git add .

6. Submit to the local warehouse

git commit -m "注释内容"

7. Create the main branch

git checkout -b main

8. Push to the main branch

git push origin main

9. Pull the remote main branch

git pull origin main

3. Other operations of git

1. develop branch

It is best to push to the develop branch every time, and then request to merge into the main branch

git checkout -b develop
git pull -r origin main   将main分支拷贝到本地
git add .
git commit -m "develop_test"
git remote add origin ssh://[email protected]/weiyuting/shortLink.git
git push origin develop
再做分支合并

2. View branch

git branch   查看本地所有分支
git status  查看当前本地所在分支
git branch -r   查看远端所有分支
git branch -a  查看本地+远端所有分支

3. Switch branches

git switch develop
git checkout develop

4. View branch history

git log

Guess you like

Origin blog.csdn.net/qq_45859826/article/details/130087059