使用Git工具

主要记录本人学习git工具过程

一、Hello world

进入github官网,点击read the guide,即学习入门hello world。
主要是学习如何在网页上操作,如何创建仓库,创建分支,对比分支,然后合并分支。

二、工具使用

2.1 安装git工具

本人使用的是Anaconda,因此直接在Prompt中,输入

conda install git

2.2 测试

随便clone一个项目到本地

cd MyProject
git clone http://github.com......

2.2 简便使用

首先在网页版新建一个仓库,然后git clone到本地。
添加文件流程:
需要将文件或文件夹复制到对应的clone目录,然后

git add filename #加入暂存区
git commit -m "comment" #提交修改
git push origin # 将本当前分支推送至origin主机对应的分支

2.3 新建分支

git branch newname#新建新分支
git checkout newname#转到新分支
git add files
git commit -m "comment"
git push origin newname:newname(git push origin newname)

2.4 全局设置

可以全局设置用户名和邮箱,作为提交者的信息

git config -- global user.name "username"
git config -- global user.email "email_adress"

每次提交远程代码的时候,都需要输入github账号密码,可以永久记住账号密码

git config --global credential.helper store

学习资料

简便版
复杂版
常用命令

猜你喜欢

转载自blog.csdn.net/hunt_ing/article/details/82319325