git的基础用法
文章目录
- 前言
- 关联仓库
- 提交代码
- 分支操作
- 账号免密
前言
记录一下git的一些基础用法。
关联仓库
# 初始化
git init# 关联仓库
git remote add origin <仓库地址># 查看当前关联的仓库
git remote -v# 一次只能remote一个,要换需要先删原来的``
git remote remove origin
提交代码
# 下载仓库
git clone <仓库地址># 拉取仓库
git pull <仓库地址># 添加文件
git add <文件名># 删除文件
git rm <文件名># 添加当前目录所有文件
git add . # 暂存
git commit -m 'V1.0.01(修改的注释信息)'# 提交代码
git push origin master
分支操作
# 创建分支
git branch <分支名称># 查看有哪些分支
git branch # 切换当前操作分支
git checkout <分支名称>
账号免密
# 保存账号密码,用户名密码输入一次即可记住账号密码
git config --global credential.helper store # 删除记住的用户密码
rm ~/.git-credentials # 取消使用记住密码
git config --global --unset credential.helper