您的位置:首页 > 其它

git基本使用

2018-01-16 09:44 330 查看

Git基本使用

问题:git是什么?有什么用?怎么用?

解答

解析

git是分布式版本控制系统

应用

用于代码管理,多人团队协助

使用

0.安装

#centos默认已安装
yum -y install git


1.安装后初始配置

#配置全局
git config --global user.name "Your Name"
git config --global user.email "email@example.com"
#查看
git config --local --list
# 配置当前git库用户
git config user.name/email


2.新建代码库

git init


把工作区的取消

git checkout -- file


查看工作区代码的修改

git diff


撤销暂存区的操作

git reset HEAD file


回滚到最新的当前分支

git reset --hard


tag回退

#先列出tag清单
git tag -l
#再回退到某个tag
git checkout <tag_name>


查看文件作者

git blame <file_name>


问题

1.git pull时需要输入账号密码

解决:

git config --global credential.helper store


例子

[root@compile Test]# git pull
Username for 'https://gitlab03.test.com': test
Password for 'https://l0995@gitlab03.test.com':
Already up-to-date.
[root@compile Test]# git config --global credential.helper store
[root@compile Test]# git pull
Already up-to-date.
[root@compile Test]# git pull
Already up-to-date.


参考

1.Git教程 - 廖雪峰的官方网站
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息