git快速入门

325 阅读1分钟

111.jpg

基本使用
git init

git remote add origin 远程仓库url

git pull origin master

git add .

git commit -m  "注释"

git push origin "master"
# 查看远程仓库地址 
git remote -v

# 将本地master分支推向远程仓库
git push -u origin master

# 删除原有的远程仓库地址
git remote remove origin

# 在本地添加远程仓库
git remote add origin https://gitee.com/zm5/demo01.git
分支命令
# 查看本地分支
git branch 

# 创建分支
git branch 分支名 

# 切换分支
git checkout 分支名 

# 创建并切换分支
git checkout -b 分支名 

# 合并分支
git merge 被合并分支名 

# 删除分支
git branch -d 被删除分支名  //删除分支时要先退出被删除分支

# 本地分支重命名
git branch -m oldBranch newBranch
其他命令
# 生成ssh秘钥
ssh-keygen -t rsa

# 撤销对该文件的所有更改
git checkout -- filename

# 将某个文件移出缓存区
git rm -r --cached "文件路径"

# 查看当前存在的版本记录
git log

# 查看所有的版本记录
git reflog

# 用户配置
git config --global --list 
git config --global user.name “用户名”
git config --global user.email “邮箱地址” 
git config --global credential.helper store    // 避免每次都输入密码

# 配置文件
C:\Users\Administrator\.gitconfig (用户信息配置)