git 常见命令

打包命令, 和远端进行对比

git diff origin/master --name-only | xargs tar cvzf ../../Users/zhengming809/Desktop/1111_aaaa.tar.gz

删除远端分支命令:

1: git push origin --delete 分支名字(比如: examination/152012_test, 注意这里不用加/,比如/examination/152012_test)

2: 推送一个空的分支到远程分支 git push origin :分支名字

恢复被 rm 后的文件

git checkout -- .

分支 直接推送到远端:
git push origin exmanation/150811_poker_guess

git 合并最新主干:

git fetch origin && git remote prune origin
git merge --no-ff origin/master
git push origin feature/150413_guessmax

git 回滚的命令
git reset --hard HEAD或版本号

git 删除分支
git checkout master // 由于不能直接删除分支
git branch -d feature/150413_guessmax

git 建立上新分支

cd /data/httpd/game5/

rm -rf wap 删除目录(这里一定要注意,不要删除别人的)

mkdir wap 新建目录

cd wap 去目录里面

git init 初始化

添加远程仓库 wap 或者pc

git remote add origin http://www:12345678@21.56.65.1/wlt_game_php/gamehall.git
git remote add origin http://www:12345678@21.56.65.1/wlt_game_php/gamepc.git

获取远端分支
git fetch --depth=1

新建分支
git checkout -b feature/150428_zhongchouluodiye origin/feature/150428_zhongchouluodiye

拷贝 wap 或者 pc 的 config.php
cp /data/httpd/game_config/gameHall/app/config.php app/
cp /data/httpd/game_config/gamepc/app/config.php app/

SVN 建立新分支

1.
去 repo-browser, 路径是
examination/youxi.wanlitong.com/trunk
右键 copy to http://10.35.52.246/svn/youxi/php/youxi.wanlitong.com/branches/2015-04-20_caidaxiao

2.
去测试环境
ssh www@25.17.1.37 / 123qwe
cd /data/httpd/game5/
cp -rf pc ./pc_bak //先备份
rm -rf pc
svn co http://192.168.42.103/svn/youxi/php/youxi.wanlitong.com/branches/2015-2-25_caipiaoTdianchonghuafei ./pc
cd pc
svn info
cd app
cp xxxx/config.php config.php

sourceTree 新建一个分支:

配置git:
新建一个目录 -> 进入目录 -> git init -> 添加工作副本 -> 选择本地文件 -> 设置 -> URL/路径
http://zhengming809:12345678@10.35.52.34/wlt_game_php/gamehall.git -> git fetch

新建一个分支:
先把 master 和 develop 同步到本地 -> git 工作流 填v -> 建立新功能 -> 自己命名一个名字

新建一个测试环境:
要先进入到 wap或者pc 里面才有 git命令
git branch -avv 查看当前的 brantch
git 工作流 建立新功能
自己命名一个名字

cd /data/httpd/game12/wap
git init
git remote add origin http://www:12345678@25.17.1.204/wlt_game_php/gamehall.git 在本地仓库上添加一个远程仓库
git fetch
git status
git checkout -b feature/150413_guessmax origin/feature/150413_guessmax
(git checkout feature/150413_guessmax) // 已经有这个分支, 则直接切换到这个分支
rm app/config.php
cp /data/httpd/game_config/gameHall/app/config.php app/config.php

sz 下载命令
rz -y 强制上传命令

测试环境冲突的解决方案: git reset --hard origin/examination/160324_pad_tuiguang

设置当前库的硬盘的值:

git config http.postBuffer 524288000

git remote -v 查看当前的远程库
git remote rm origin 删除远程库

// 设置和修改远端对应的分支

git remote set-url origin http://www:12345678@21.56.65.1/wlt_game_php/gamehall.git
git remote set-url origin http://www:12345678@21.56.65.1/wlt_game_php/gamepc.git

原文地址:https://www.cnblogs.com/zhengming2016/p/6992123.html