Git的使用

Git-1

首先声明账户
git config --global user.name xxxx
git config --global user.email xxxxx@qq.com

创建文件夹后建立仓库
git init 建立仓库
git status 查看状态
Untracked files 还没跟踪

添加到本地仓库
git add . 添加当前目录文件
git add index.txt 添加指定文件

git commit -m “init” 提交
git commit -m ‘add read.txt’ -m后面是注释

总结
先造文件
再看状态 发现新文件,还没跟踪
添加进来

工作区
a.php , b.php
工作区add一下存到暂存区

再commit 一下来到版本库

修改文件
需要先add index.txt
再git commit -m ‘modify’

删除文件
git rm read.txt
git commit -m “del read.txt”

Git-2

推送项目
git push https://gitee.com/xxxx/first-one.git master

git config --system --unset credential.helper 重置用户名和密码

别名
git remote add origin https://gitee.com/xxxx/first-one.git

同步远程仓库
git push -u origin master

git remote -v

git remote rm origin

Git-3

来到其他盘,模仿其他用户
克隆
git clone https://git.oschina.net/xxxx/first-one.git

拉取项目
git pull first-one master

git add .
git commit -m “”
git push origin master

查看日志
git log

单行显示
git log --pretty=oneline

倒退版本
git reset --hard HEAD^^^^^
HEAD代表最新的版本 ^代表往前退五个版本

建议用版本号切换
git reset --hard 2580d(版本号)

git reflog 历史操作

http://blog.sina.com.cn/s/blog_6aebf01f0101fugz.html

https://www.aliyun.com/jiaocheng/11268.html

Git-4

分支管理
查看分支
git branch
创建test分支
git branch test
切换分支
git checkout test
合并分支
切到master 再合并
git merge test
删除分支
git branch -d test
git checkout -b test

远程仓库
查看远程仓库
git remote -v
删除远程仓库别名
git remote remove 远程库名
添加远程库别名
git remote add 别名 地址
git push origin master

配置公钥
配ssh地址
创建公钥
ssh-keygen -t rsa -c email(邮件) 一路回车
在c盘下找到.ssh文件中找到公钥 -pub
复制,在远程仓库建立公钥,粘贴

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

end for time

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值