Liunx——Git工具使用
目录
1)使用 git 命令行安装 git
2)在 Gitee 创建仓库
创建仓库
3)Linux克隆仓库到本地
1.三板斧第一招: git add
2.三板斧第二招: git commit
3.三板斧第三招: git push
5)所遇问题
解决git上传提交的时出现:Please tell me who you are.问题
1)使用 git 命令行安装 git
yum install git
2)在 Gitee 创建仓库
参考文章
新手使用——Gitee教学_gitee新手_IfYouHave的博客-CSDN博客https://blog.csdn.net/IfYouHave/article/details/129005774
创建仓库
1. 登陆成功后, 进入个人主页, 点击左下方的 New repository 按钮新建项目
2. 然后跳转到的新页面中输入项目名称(注意, 名称不能重复, 系统会自动校验. 校验过程可能会花费几秒钟). 校验 完毕后, 点击下方的 Create repository 按钮确认创建.
仓库名称尽量采用英文,初始化创库,模板通常选择Readme文件
3. 在创建好的项目页面中复制项目的链接, 以备接下来进行下载.
一般都使用HTTPS链接
3)Linux克隆仓库到本地
创建好一个放置代码的目录.
git clone [url]
依次输入gitee注册是使用邮箱或者手机号,其次输入密码
sucess后
这里的 url 就是刚刚建立好的 项目 的链接.
4)提交代码三板斧:
1.三板斧第一招: git add
将代码放到刚才下载好的目录中 git clone [url]
git add [文件名]
将需要用 git 管理的文件告知 git
2.三板斧第二招: git commit
提交改动到本地
git commit .
最后的 "." 表示当前目录 提交的时候应该注明提交日志, 描述改动的详细内容.
3.三板斧第三招: git push
同步到远端服务器上
git push
需要填入用户名密码. 同步成功后, 刷新 Github 页面就能看到代码改动了.
4.提交记录:git log
git log
查看历史提交记录
5.编辑.gitignore
vim .gitignore
通过编辑此文件,可以将不想要提交的一些文件的后缀加入,就会进行屏蔽
6.删除文件git rm 文件名
git rm 文件名
删除后执行三板斧,代码托管中心的远程仓库也会删除
5)所遇问题
解决git上传提交的时出现:Please tell me who you are.问题
* Please tell me who you are.Rungit config --global user.email "you@example.com"git config --global user.name "Your Name"to set your account's default identity.
Omit --global to set the identity only in this repository.fatal: empty ident name (for <customer@VM-4-10-centos.(none)>) not allowed
提示:Please tell me who you are.
翻译过来就是:请告诉我你是谁。
就是说这里git无法识别你是谁,你需要告诉 git 你的身份。
其实提示已经告诉了你的问题:git config --global user.email "you@example.com" git config --global user.name "Your Name"
解决办法是在 终端命令行,依次输入以下命令并依次输入你的邮箱与名称:
git config --global user.email "邮箱" git config --global user.name "名称"
在命令行输入回车之后,使用以下命令查看git 信息
git config -l
继续提交即可