如何生成密钥
git ssh
git clone
git add --all
git commit -m 'up'
git ssh 生成。在企业中如果企业中的运维要,那你就给这个pub 文件就对了
git config --global user.name ""
git config --global user.email "你自己的邮箱"
ssh-keygen -t rsa -C "你自己的邮箱"
id_rsa.pub 密钥文件
每天如何操作git 一般习惯是什么样的,一个模块或一个页面或一个功能为单位
git add git commit 多次添加多次提交。 而git Push 或pull 一般为早晨 和中午 或下班前 提交,这个操作意味着你要提到远程仓库,让别人看到,让是不管电脑坏不坏,公司仓库代码是有的。
中间如果要上线,或别人需要,那push 也是可以的,其他就不要频繁操作,那样别人会不断的更新。
以下是一下常用的命令。分享一下
git 有github 这个是开源的,个人的项目可以被别人看见的,公司的项目一定不能公开放上去,要有法律责任的
bitbucket.org coding gitee 等这些都是做私有仓库的。还有就是自己搭建一下,其实也挺方便的。本地文件上传线上 git仓库
没有文件夹
mkdir myproname
cd myproname
已存在文件夹
cd mypro name
初始化
git init
添加
git add --all
提交
git commit -m '提交'
remote
git remote add origin https://git.coding.net/xxx/ke.xxx.com.git
提交
git push -u origin master
git pull --rebase origin master
GIT 常用命令:
$ cd E:转到e盘 $ ls查看此处目录 $ cd fe/转到fe文件夹 git 常用命令 1、git clone命令——用于克隆项目git库,git clone git@库地址:库名 例如 git clone git@172.16.33.3:testcrm 2、git branch命令,用于操作分支 git branch 分支名 //添加本地分支 例如 git branch feature 添加feature分支 git branch -d 分支名 //删除本地分支 例如 git branch -d feature 删除feature分支 git branch -a 查看本地分支和远程库的分支 3、git checkout feature //切换分支 4、git pull origin feature 从远程拉取分支与当前分支合并 5、git fetch origin feature:feature 从远程分支feature分支拉取到本地命名为feature 6、git merge -no-ff -m "text" feature 将feature分支合并到当前分支下(所处的分支) 7、git tag 添加标签 git tag testscrm-develop-201505081353 库名-分支名-年月日时分 8、git push origin feature 将feature分支推送到服务器 git push origin tags 将标签推送到服务器 9、git status 查看更改的文件 10、git add 更改的文件名 例如 git add html/index.html 添加更改的index.html(按查看结果的路径走) 11、 git commit -m "备注" //添加备注并提交 git rm file url -r 12、git checkout –b branch hotfix 案例1,本地无testcrm库时,需要将testcrm库中的feature分支合并到develop分支 一、获取仓库 在F盘中选择git bash,进入操作 git clone git@172.16.33.3:testcrm 克隆项目库 cd testcrm 进入新增目录 git branch -a 查看本地分支和远程库的分支 二、切换分支 git checkout develop 切换到develop分支 三、拉取分支 git fetch origin feature:feature 拉取feature分支 四、合并feature分支到develop分支,将feature分支合并到develop分支下,处于develop分支下 git merge –no-ff –m “merge 201509071552” feature 合并feature分支到develop分支 (git merge --no-ff -m "merge 201509081552" feature) git log 查看提交记录 五、添加标签 git tag testcrm-develop-201509071558 // 库名+分支名+添加标签的时间(年月日时分) 六、推送分支到服务器 git push origin develop 七、推送标签到服务器 git push origin --tags 案例2,本地有testcrm分支,需要将develop与feature分支合并 一、更新testcrm目录,右键git bash 进入git命令 git checkout develop 切换到develop分支 git pull origin develop 更新develop分支 二、更新feature分支 git fetch origin feature:feature (或者切换到feature分支下,执行 git pull origin feature) 三、合并分支,将feature分支合并到develop分支下,处于develop分支 git merge -no-ff -m "merge 201509071552" feature git log 查看提交记录 四、添加标签 git tag testcrm-develop-201509071558 //项目库名-分支名-添加标签的时间(年月日时分) 五、推送分支到服务器 git push origin develop 六、推送标签到服务器 git push origin tags