git 使用

  317  git commit -m "add txt"
  318  git push -u origin
  319  ls
  320  cd configserver/

  340  git fetch    是不变的
  341  ls
  342  git status    查看所有状态
  343  git branch -r   查看所有分支
  344  pull = fetch + merge
  345  git merge origin/master 
  
  
拉取分支 git pull origin master
  
  
查看远程分支
git branch -a

查看本地分支
git branch
  
删除分支
git  branch -d  分支名字

删除远程分支
git push  origin  --delete  分支名字

显示所有分支
git branch -a

合并分支


1. 创建分支
git checkout -b fengjian
2. 修复代码
 echo "fix" > index.html
 git add  index.html
 git commit -m "fix  index.html"
3. 切换到 master分支
git  checkout master
3. 合并分支,推动到远程master
git  merge  fengjian
git push origin master



推送到远程其他分支
git push  origin    fengjian


3. 使用git clone
git config --global user.name "fengjian"
git config --global user.email "fengjian@senyint.com"

ssh-keygen -t rsa -C "fengjian@senyint"


初始化配置git 用户名和email
git config  --global  user.name "fengjian"
git config  --global  user.email fengjian@senyint.com


查看配置信息
git  config  --list


解决冲突
172.16.161.145 
1. 修改 Dockerfile 文件,添加 一行 11111111
git  add  Dockerfile
git commit  -m  "update Dockerfile 111111111"

172.16.161.149
2. 修改Dockerfile 文件, 添加一行22222222
git  add  Dockerfile
git commit  -m  "update Dockerfile 2222222"

#合并master
git pull origin master
 
From 172.16.161.149:HIP/configserver
 * branch            master     -> FETCH_HEAD
Updating 17a97de..ab57c2a
error: Your local changes to the following files would be overwritten by merge:
    Dockerfile
Please, commit your changes or stash them before you can merge.
Aborting

修改 Dcokerfile, 删除head 和================
再次提交

 
删除文件
1.进入到目录中  rm  xxx.txt  -rf
2. git add -A 或者 git rm  xxx.txt
3. git commit -m "delete xxx.txt"
4. git push  origin master


添加新的仓库
mkdir docker
cd docker/
git init
git remote add origin  http://172.16.161.149/HIP/docker.git
git remote show origin

远程仓库重命名
cd existing_repo
git remote rename origin old-origin
git remote add origin http://testgit.cinyi.com/HIP/docker.git
git push -u origin --all
git push -u origin --tags



具体操作流程
svn checkout http://172.16.161.26:99/svn/EMDI
cd EMDI/03-实现/源程序/EMDI/
git init
git remote add origin  http://172.16.161.149/platform/emdi.git
git add .
git commit -m "Initial commit"
git push origin master

切换分支
git checkout -b 大连附一
git branch
echo 11111 > book.txt
git add book.txt
git commit -m "branch fengjian  add book.txt"
git push origin 大连附一

指定远程分支下载到本地
git pull origin dev2:dev2

 

posted @ 2016-09-22 15:55  fengjian1585  阅读(226)  评论(0编辑  收藏  举报