批量添加(先添加再上传)
svn st | grep '^\?' | tr '^\?' ' ' | sed 's/[ ]*//' | sed 's/[ ]/\\ /g' | xargs svn add 
svn ci -m '' ./
亲测可用
https://blog.csdn.net/jw20082009jw/article/details/70184559
 
批量删除(先删除再上传)
svn st | awk '{if ($1 == "!") {print $2}}' | xargs svn rm
svn ci -m '' ./
亲测可用
https://www.cnblogs.com/kyoung/p/6933528.html
 
比较版本差异

svn diff Script/activity/CannonKing.js -r208:209

 
创建分支

svn cp -m 'create branch' http://www.svnchina.com/svn/bobo_game/mrsd http://www.svnchina.com/svn/bobo_game/mrsdfb

 
从主干合并到分支

svn merge http://www.svnchina.com/svn/bobo_game/mrsd/Script ./Script


GIT相关命令
首先指定目录并add相关修改(增删改)
然后commit->push(无需指定目录)
事前最好拉到最新代码pull
拉新分支
git checkout --track  origin/PlayBalls_facebook
切换分支
git checkout master
git checkout PlayBalls_facebook
 
git status
git add .
git add -A
 
批量操作多个文件
git add/rm/checkout xxx1.cs xxx2.cs ...
git add/rm/checkout "xxx 1.cs" "xxx 2.cs" "xx叉叉.cs" ...//有空格、中文的情况
git commit -m "xxxx"
git push 
git log ./script/yixia/code/prefab/Map.js 
git diff d6be022c3b07be602230958d8d5671858035b48a ./script/yixia/code/prefab/Map.js

 

 
分支间选择性合并
//在小分支修改了东西并提交之后,记录提交的哈希值
//切换到 master 分支
git checkout master
//挑选3号樱桃
git cherry-pick 9e2d49b
cherry-pick相当于commit
最后push
 
cherry-pick 后不自动提交
git cherry-pick -n 9e2d49b
 
cherry-pick 一次merge
cherry-pick merge的commitId -m 1
 
合并其他分支的单个文件到主干(文件替换)

git checkout en script/base/Util.js

 

git通配符

git status *.lua//单个的情况

git status *.{lua,cs}//多个的情况

git status * | egrep ".lua|.prefab"

$ git status | grep "added by us"

$ git status | grep xxx.cs

 

全体合并

git merge en

合并后变更合并新做一次提交

git merge --squash en

无历史信息的强制合并

git merge overseas/aar --allow-unrelated-histories

 

清除本地新增

git clean -df

 

删除本地分支

git branch -D developer/xxx

删除远程分支

git push origin --delete developer/xxx

 

拉取远端分支

git checkout -b developer/xxx(本地分支名称) origin/developer/xxx(远端分支名称)

 

更新并合并到本地

git pull origin cn_dev

 

提交

git push origin HEAD:developer/xxx

 

解决冲突

对于both added/both modified
git checkout --theirs[mine] Assets/GameMain/UI/UIForms/WorldMap/WorldMapPanel.prefab

对于added by us/them、deleted by us/them
git rm <file-name>和git add <file-name>来删除/添加file
在此过程中需要特别注意谁是us,谁是them。

撤销add

git reset Assets/GameMain/Scripts/DataTableNewGen/WorldIntercontinentalCfg.pb.cs

 

撤销commit

git revert <commit_id>
git push
revert后要push

 

查看一次提交的内容(某文件)

git show d6d34bf0d36774b86603cf0cf1be8143364b962a Assets/GameMain/Scripts/Story/StoryCommand/StoryCommand.cs

 

查看一次提交了哪些文件

$ git show --raw c57c66786b309a80075fa8d22414dfdb960e18fa

git whatchanged d6d34bf0d36774b86603cf0cf1be8143364b962a 

 

查看已删除的文件的提交记录

$ git log --oneline --follow -- xxx.cs
94e665e2f 迁移overseas分支
fab301111 patch from 2022-11-18 22:23:55

查看提交中的文件情况

$ git show --raw 94e665e2f | grep xxx.cs
:100644 000000 237ea5e97 000000000 D xxx.cs
:100644 000000 6f63326ed 000000000 D xxx.cs.meta

查看某作者的log

git log --author="fengkerong"

git log --author="liang.b.chen@dena.com\|kerong.feng@dena.com"

设置查看条数

git log -1 xxx.cs

按提交信息筛选log

git log --grep=xxxx的提交信息(可部分匹配)

查看本地全分支提交记录(--graph --all)

git log --author kerong --graph --all Assets/Script/Base/Service/xxx.cs

查看单个文件

git log -- Assets/ResAssetBundles/Prefabs/UI/Crusade/UICrusadeEnvironmentSelectDialog.prefab

查看远端、本地分支下的单个文件

git log origin/release/obt_ios_cqc -- Assets/ResAssetBundles/Prefabs/UI/Crusade/UICrusadeEnvironmentSelectDialog.prefab

 

更改分支名字

git branch -m old_name new_name

 

查看已add的修改

git diff --cached Assets/GameMain/Scripts/UI/Login/LoginServerPage.cs

 

回退至某次提交

git reset --hard e35b93ef1d709156a4fa6c1260c45e9d2668c84f

后强推至远端

git push -f -u origin developer/fengkerong/1_92

 

打包压缩

git archive -o ../latest.zip HEAD

 

解决分支冲突

git pull : error: cannot lock ref 'refs/remotes/origin/*' (unable to update local ref)

  1. git gc --prune=now
  2. git remote prune origin
  3. git pull
git强制覆盖本地使其与远端一致:
    git fetch --all
    git reset --hard origin/master
    git pull origin master

 

$ ssh-keygen //生成SSH密钥z指令(采用ssh协议通讯时)
git clone url //下载服务器上的代码到本地,url为代码的地址‘
git branch branchName//创建一个名为branchName的分支,但不切换到该分支
git checkout -b branchName //创建一个名为branchName的分支并切到该分支
git checkout -b branchName —track origin/branchName //在本地创建一个名为branchName的分支,同时自动绑定服务器上的该分支
git pull origin/branchName //从远端更新代码带本地,并自动merge代码
git merge branchName //合并branchName分支的代码,将其合并到当前分支
git branch -a //查看所有分支信息,包括远端分支
git add * //将当前文件 夹下的本地更改和添加的新文件进行保存
git add filePath //将filePath下的文件的本地更改和添加的新文件进行保存
git rm * //将当前文件夹下的已删除文件的删除操作保存
git rm filePath //将filePat h下的已删除文件的删除操作保存
git diff filePath //查看filePath下的文件修改内容
git diff //查看距离上次git add 操作之前的所有修改过的文件的修改内容
git status //查看当前项目距离上次git add 操作之后的所有的修改,删除,新加的文件路径和名称
git checkout * //将当前文件夹下的文件操作还原到上次git add 之前
git checkout filePath // 将filePath下的文件的修改操作还原到上次git add 之前
git commit -m “” //将本地更改提交
git push origin branchName //将本地更改推送到远端服务器
git reflog // 查看log信息
git reset —hard versionNumber // 强制将代码还原到某个版本,特别慎用,因为有可能会损坏其他人的代码修改


git 子模块


git submodule add url //将一个仓库当作子模块加载到当前仓库里,url为作为子模块被加进来作为子模块的仓库
git submodule update //更新子模块,更新子模块的另外一个方法,是进入到子模块所在的文件夹,然后像修改普通的git的仓库的方式进行更新和切换分支
git submodule init //下载服务器上的子模块到本地


git行尾符


git config --global core.autocrlf true //提交时转换为LF,检出时转换为CRLF
git config --global core.autocrlf input //提交时转换为LF,检出时不转换
git config --global core.autocrlf false //提交检出均不转换
git config --global core.safecrlf true //拒绝提交包含混合换行符的文件
git config --global core.safecrlf false //允许提交包含混合换行符的文件
git config --global core.safecrlf warn //提交包含混合换行符的文件时给出警告

 

gitlab相关操作

Squash一般不要勾选,否则会合并merge request中的全部commit成一个commit

Squash and merge (FREE)

As you work on a feature branch, you often create small, self-contained commits. These small commits help describe the process of building a feature, but can clutter your Git history after the feature is finished. As you finish features, you can combine these commits and ensure a cleaner merge history in your Git repository by using the squash and merge strategy.

  • Small commits are joined together, making it simpler to revert all parts of a change.
  • When the single commit merges into the target branch, it retains the full commit history.
  • Your base branch remains clean, and contains meaningful commit messages.

Each time a branch merges into your base branch, up to two commits are added:

  • The single commit created by squashing the commits from the branch.
  • A merge commit, unless you have enabled fast-forward merges in your project. Fast-forward merges disable both merge commits and squashing.

By default, squashed commits contain the following metadata:

  • Message: Description of the squash commit, or a customized message
  • Author: User that created the merge request
  • Committer: User who initiated the squash

Project owners can create new default messages for all squash commits and merge commits.

 

工程锁住报错的解决方案

$ git rm Assets/Script/Game/UI/Home/Equipment/temp/UIEquipmentManageDialog.cs
fatal: Unable to create 'E:/client2/.git/index.lock': File exists.

直接把E:/client2/.git/index.lock删掉即可