9.2 KiB
前言
因为GameplayAbility属于蓝图c++混合编程框架,所以对蓝图类与地图进行版本管理是十分重要的事情。所以本文将在这里介绍git的二进制文件版本管理方案。
使用过程
- 下载Gitlfs:https://git-lfs.github.com/~~(现在的git都自带lfs,就算没有下个SourceTree也会自带lfs)
- 使用cmd,cd到git仓库所在目录,执行git lfs install。(一般人都在这一步做错,如果做错会存在100mb的文件大小限制)
- 此时目录下会出现.gitattributes文件,它用于设置监视的扩展名,你可以通过输入
git lfs track "*.扩展名"
的方式来添加扩展名。例如想要监视uasset,就输入git lfs track "*.uasset"
。最后将.gitattributes加入进版本管理:git add .gitattributes
。 - 现在你就可以用与管理代码文件相同的方式,管理二进制文件了。
git add file.uasset
git commit -m "Add design file"
git push origin master
推荐使用SourceTree,因为如果你第二步操作有误或是第三步没有添加扩展名,它会提醒你的。
蓝图合并与Diff工具
Merge:https://github.com/KennethBuijssen/MergeAssist Diff:https://github.com/SRombauts/UE4GitPlugin
LFS upload missing objects 解决
输入命令,即可
git config --global lfs.allowincompletepush false
LFS删除 很久不用的文件
使用prune命令可以删除LFS中的旧文件。
git lfs prune options
这会删除认为过旧的本地 Git LFS文件,没有被引用的文件被认为是过旧的文件:
当前切换的提交 一个还没有被推送的提交(到远程,或者任何在lfs.pruneremotetocheck设置的)
一个最近的提交 默认,一个最近的提交是过去十天的任何一个提交,这是通过添加如下内容计算的:
在获取附加的Git LFS历史部分讨论过的lfs.fetchrecentrefsdays属性的值。
lfs.pruneoffsetdays属性的值(默认为3)。
git lfs prune
你可以为配置一个持用Git LFS内容更长的时间:
don't prune commits younger than four weeks (7 + 21)
$ git config lfs.pruneoffsetdays 21 不像Git内置的垃圾回收, Git LFS内容不会自动删除,因此定期执行git lfs prune来保留你本地的仓库文件大小是很正确的做法。
你可以测试在git lfs prune –dry-run命令执行后有什么效果:
$ git lfs prune --dry-run ✔ 4 local objects, 33 retained 4 files would be pruned (2.1 MB) 更精确地查看哪个Git LFS对象被删除可以使用git lfs prune –verbose –dry-run命令:
$ git lfs prune --dry-run --verbose ✔ 4 local objects, 33 retained 4 files would be pruned (2.1 MB)
- 4a3a36141cdcbe2a17f7bcf1a161d3394cf435ac386d1bff70bd4dad6cd96c48 (2.0 MB)
- 67ad640e562b99219111ed8941cb56a275ef8d43e67a3dac0027b4acd5de4a3e (6.3 KB)
- 6f506528dbf04a97e84d90cc45840f4a8100389f570b67ac206ba802c5cb798f (1.7 MB)
- a1d7f7cdd6dba7307b2bac2bcfa0973244688361a48d2cebe3f3bc30babcf1ab (615.7 KB) 通过使用–verbose模式输出的十六进制的字符串是被删除的Git LFS对象的SHA-256哈希值(也被称作对象ID,或者OIDs)。你可以使用在找到引用某个Git LFS对象的路径或者提交章节介绍的技巧去找到其他想要删除的对象。
作为一个额外安全检查工作,你可以使用–verify-remote选项来检查Git LFS store是否存在想要删除的Git LFS对象的拷贝。
$ git lfs prune --verify-remote ✔ 16 local objects, 2 retained, 12 verified with remote Pruning 14 files, (1.7 MB) ✔ Deleted 14 files 这让删除过程非常的非常的缓慢,但是这可以帮助你明白所有删除的对象都是可以从服务器端恢复的。你可以为你的系统用久开启–verify-remote 选项,这可以通过全局配置lfs.pruneverifyremotealways属性来实现。
$ git config --global lfs.pruneverifyremotealways true 或者你可以通过去掉–global选项来仅仅为当前会话的仓库开启远程验证。
Git代理
配置Sock5代理
git config -–global http.proxy socks5://127.0.0.1:2080 git config –-global https.proxy socks5://127.0.0.1:2080
只对github.com
git config --global http.https://github.com.proxy socks5://127.0.0.1:2080 git config --global https.https://github.com.proxy socks5://127.0.0.1:2080
取消代理
git config --global --unset http.https://github.com.proxy) git config --global --unset https.https://github.com.proxy)
增加超时时间
git -c diff.mnemonicprefix=false -c core.quotepath=false --no-optional-locks push -v --tags origin GamePlayDevelop:GamePlayDevelop
Pushing to https://github.com/SDHGame/SDHGame.git
LFS: Put "b6a8fa2ba0
": read tcp 127.0.0.1:56358->127.0.0.1:1080: i/o timeout
LFS: Put "76473fed07
": read tcp 127.0.0.1:56360->127.0.0.1:1080: i/o timeout
LFS: Put "78a0819db8
": read tcp 127.0.0.1:56374->127.0.0.1:1080: i/o timeout
LFS: Put "24ab214470
": read tcp 127.0.0.1:56376->127.0.0.1:1080: i/o timeout
Uploading LFS objects: 99% (712/716), 210 MB | 760 KB/s, done. error: failed to push some refs to 'https://github.com/SDHGame/SDHGame.git'
git config --global lfs.tlstimeout 300 git config --global lfs.activitytimeout 60 git config --global lfs.dialtimeout 600 git config --global lfs.concurrenttransfers 1
LFS Upload Failed (miss) 文件路径
解决方案:下载所有LFS数据:git lfs fetch --all
服务器上不存在
解决方案:上传指定lfs文件:git lfs push origin --object-id [ID]
LFS objects are missing on push
GitLab checks files on push to detect LFS pointers. If it detects LFS pointers, GitLab tries to verify that those files already exist in LFS. If you use a separate server for Git LFS, and you encounter this problem:
- Verify you have installed Git LFS locally.
- Consider a manual push with
git lfs push --all
.
强制上传LFS
git lfs push origin --all
I/O timeout when pushing LFS objects
If your network conditions are unstable, the Git LFS client might time out when trying to upload files. You might see errors like:
LFS: Put "http://example.com/root/project.git/gitlab-lfs/objects/<OBJECT-ID>/15":
read tcp your-instance-ip:54544->your-instance-ip:443: i/o timeout
error: failed to push some refs to 'ssh://example.com:2222/root/project.git'
To fix this problem, set the client activity timeout a higher value. For example, to set the timeout to 60 seconds:
git config lfs.activitytimeout 60
引擎Content管理
.gitignore文件中添加
Content/
#Content/
!*.uasset
**/Content/*
**/Content/*/*
!**/Content/EngineMaterials/
!**/Content/EngineMaterials/ToonTexture/
解决git UTF8文件乱码问题
问题:
未处理的异常:System.ArgumentException: Path fragment '“Content/\351\237\263\351\242\221/Cheetah\302\240Mobile_Games_-_\347\254\254\345\215\201\344 \270\203\345\205\263\302\240Cube\302\240\345\207\240\344\275\225\350\277\267\351\230\265.uasset”包含无效的目录分隔符.
1> 在 Tools.DotNETCommon.FileSystemReference.CombineStrings(DirectoryReference BaseDirectory, String[] Fragments)
1> 在 Tools.DotNETCommon.FileReference.Combine(DirectoryReference BaseDirectory, String[] Fragments)
1> 在 UnrealBuildTool.GitSourceFileWorkingSet.AddPath(String Path)
1> 在 UnrealBuildTool.GitSourceFileWorkingSet.OutputDataReceived(Object Sender, DataReceivedEventArgs Args)
1> 在 System.Diagnostics.Process.OutputReadNotifyUser(String data)
1> 在 System.Diagnostics.AsyncStreamReader.FlushMessageQueue()
1> 在 System.Diagnostics.AsyncStreamReader.GetLinesFromStringBuilder()
1> 在 System.Diagnostics.AsyncStreamReader.ReadBuffer(IAsyncResult ar)
1> 在 System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
1> 在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
1> 在 System.IO.Stream.ReadWriteTask.System.Threading.Tasks .ITaskCompletionAction.Invoke(Task completingTask)
1> 在 System.Threading.Tasks.Task.FinishContinuations()
1> 在 System.Threading.Tasks.Task.Finish(Boolean bUserDelegateExecuted)
1> 在 System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)
1> 在 System.Threading.Tasks.Task.ExecuteEntry(Boolean bPreventDoubleExecution)
1> 在 System.Threading.ThreadPoolWorkQueue.Dispatch()
git config --global core.quotepath false