1.git

1.git下载:

下载地址:http://git-scm.com/  (下不下来就微信上找记录)

验证:git --version

2.什么是git用于代码管理)

1.git_第1张图片

 

 

 

 

3.如何将码云与本地关联起来:

1.码云网址:https://gitee.com/     注册账号:cjlnj   密码:153399cyy

2.新建仓库:【码云】

3.线上线下关联:

· 鼠标右键选择Git Bash Here->输入ssh-keygen  -t   rsa  -C "[email protected]"

· 生成公钥:输入cat  ~/.ssh/id_rsa.pub

· 公钥放在码云:【码云】头像->设置->SSH公钥->把公钥复制进去,填写标题

· 本地设置姓名:git  config   --global  user.name  "cjl"

· 本地设置邮箱:git  config  --global  user.email  "[email protected]"

· 克隆项目到本地:【码云】我的->仓库->项目->选择文件master->克隆/下载->选择SSH->复制里面的地址

                    Git Bash里】输入:git  clone [email protected]:cjlnj/hnzh.git

· 写入或复制自己的代码进去:

· 将本地项目上传:【码云】新建分支:我的->仓库->项目->分支->新建分支test

                    Git Bash里】输入:

         · (将线上更新到本地 git pull)->切换分支 git chekout 分支名->

         · 本地保存到缓存 git  add   . (如果提示the file will have its original line endings in our working directory,则需   要输入:git config --global core.autocrlf false)->

         · 提交  git commit -m "子分支提交"->

         · 回到主分支 git checkout master->把新加的内容添加到主分支上 git merge 分支名->把代码推到线上 git push

将主分支同步到子分支:

· 切换到主分支后 git pull

· 切换到子分支 git checkout 子分支名

· 子分支上执行 git merge master,将主分支的代码同步到子分支上

· git status 在子分支查看当前代码状态

· git add . 将代码添加到本地仓库

· git commit -m "主分支同步子分支"

· git push 将同步后的代码上传到服务器

 

4.git常用操作:

1.git_第2张图片

 

你可能感兴趣的:(1.git)