git installation and operation

GIT

Manual version controller
Save the content of different stages of the project through manual copy behavior, add some appropriate description text to distinguish

Cumbersome and error-prone
Produce a lot of duplicate (redundant) data
Common version control tool
CVS
SVN
Git
# git three areas
Work area
Temporary area
git warehouse

git course

  1. installation
  2. config configuration name and email
  3. View. git hidden directory
  4. Check whether the current directory is managed by git (with or without .git)
  5. Initial warehouse git init
  6. add content
  7. Delete (delete sub-level, need to submit after deletion)
  8. Change (you need to add again after changing)
  9. After modifying the code in this branch, use git statue to view the file you modified
    git diff to view the specific content of the modified file

git operation process

git config user.name "你的姓名"
git config user.email "你的邮箱"
查看工作区状态
git status
添加工作区到暂存区
git add 1.txt 
##添加所有文件
git add .
##将暂存区提交到本地仓库
git commit -m

go hub

First register an account,
use ssh link to
generate ssh key

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

Add public key on github
Personal Center -> Settings -> ssh -> Add

Create a remote warehouse
link

git remote add origin [email protected]:miaov-zmouse/kkb-test.git

Synchronize local warehouse to remote

git push -u origin master

Remote branch

# 提交到远程(分支)
git push origin [本地分支名称]:[远程分支名称]

# 远程先创建好分支然后拉取到本地
git checkout -b [本地分支名称] origin/[远程分支名称]

# 拉取远程分支到本地
git pull origin [远程分支名称]:[本地分支名称]

# 查看远程仓库
git remote show origin

# 查看本地分支
git branch

# 查看远程分支
git branch -r

# 查看所有分支
git branch -a

# 删除本地分支
git branch -d [本地分支名称]

# 删除远程分支
git push origin --delete [远程分支名称]
# or
git push origin :[远程分支名称]

# 设置默认提交分支
git branch --set-upstream-to=origin/[远程分支名称] [本地分支名称]

Guess you like

Origin blog.csdn.net/weixin_54645137/article/details/112907573