0、下载git并完成安装
-
进入如下链接完成自己想要的git版本下载:git下载
-
一路默认选择,完成git安装
安装成功标志:
1、git用户设置
git config --global user.name '自己取的名字'
git config --global user.email '自己的一个邮箱'
2、本地建立仓库
电脑打开你想要建立仓库的位置,鼠标右击,点击git bash here 。
mkdir 仓库名称
cd 仓库名称
git init (初始化该文件夹为一个git仓库)
可以新建一个文件README.txt
vim README.txt ----写入相应的数据
git add . 或者 git add README.txt
git commit -m "提交说明" =====》本步骤可以直接使用git commit 然后写入相应备注
**commit**的标准如下可参考附录(1,2)
查看当前情况
git status
查看日志
git log
3、建立远程仓库
首先,打开你的github网页(没有账号的需要注册一个),然后点击your repositories
其次,点击New
最后 ,新建仓库:输入你的仓库名称、描述,选择公开还是私有,是否添加README
4、本地仓库推送到远程仓库
两步操作:
-
本地仓库连接远程仓库
git remote add origin https://github.com/用户名/远程仓库名称.git
-
push到远程仓库
git push origin '分支名(默认为main)' 可以在settings–>repositories–>把main改为master–>点击update 这样符合我们的使用习惯
5、一些简单操作
查看分支:
git branch
创建分支:
git branch -M 分支名
切换分支:
git checkout 分支名/ git switch 分支名
创建分支并切换到该分支:
git checkout -b 分支名
删除分支:
git branch -d 分支名
远程克隆仓库到本地:
git clone https://github.com/用户名/远程仓库名称.git
远程克隆特定分支到本地:
git clone -b [分支名称] https://github.com/用户名/远程仓库名称.git
远程拉取仓库:
git pull https://github.com/用户名/远程仓库名称.git
6、trouble shooting
1、git 总是弹出 openssh 对话框提示输入账号的问题
解决方案:修改为SSH模式就可以了
git remote -v
查看当前的git仓库remote方式
修改为ssh方式
git remote set-url origin git@github.com:用户名/仓库名.git
修改为https方式
git remote set-url origin https://github.com/用户名/仓库名.git
附录
commitizen
中文规范
AngularJS 规范
–END–