他说第一次用Git,问我有什么经验?
2020-03-07 本文已影响0人
captainLii
最近有点忙,忙就对了!
今天有个实习小伙伴问我一个问题,"",好的,谁叫我有问必答,不管大小,不管深浅。我都会耐心讲解。让他最快上手。
下载安装
官网
下载安装则可
全局配置用户、密码
命令:
1、全局配置用户名(xxx:对应的用户名)
$ git config --global user.name "xxx"
2、全局配置邮箱(xxx@xx.com:对应的邮箱)
$ git config --global user.email "xxx@xx.com"
创建一个仓库(拉取一个gitLab/gitHub项目)
命令:
1、在你想要存入项目的目录,创一个(本地)仓库
$ git clone http://gitlab.xxx.com/xxx/captaindemo.git

创建的开发分支
命令:
$ git checkout -b mydev
- 查看本地有哪些分支
$ git branch
- 切换分支
$ git checkout [分支名称]

提交代码--使用命令提交
(1)推送现有文件夹
命令:
$ cd existing_folder
$ git init
$ git remote add origin http://gitlab.xxx.com/xxx/xxxx.git
$ git add .
$ git commit -m "我要提交文件夹"
$ git push -u origin mydev
(2)提交增加内容
命令:
- 向提交本地仓库提交
$ git add .
- 添加说明
$ git commit -m "我加了xxx功能"
$ git push -u origin mydev
(3)推送现有的Git存储库
命令:
cd existing_repo
git remote rename origin old-origin
git remote add origin http://gitlab.xxxx.com/xxxx/xxx.git
git push -u origin --all
git push -u origin --tags
提交代码--IDE提交
-
前提IDE打开对应的项,允许Git关联,或者给项配置对应的git远程仓库
1、提交前要pull下远程master,确定没有冲突
2、提交至本地仓库
(1)

(2)

3、提交到远程仓库
(1)

(2)


声明:原创,欢迎转载~! 感谢谢您的关注,谢谢~!