在UE中使用Git进行版本控制

The Source Control provided in Unreal Editor allows you to implement basic functions such as version submission/version comparison/reverting changes through Git for blueprint projects, which is far less powerful than Git Bash, but the Diff between BluePrints is still very useful.

Before executing Git version control in UE, it is best to perform some global initialization operations in Git Bash.

1
2
$ git config --global user.name "Your Name"
$ git config --global user.email "email@example.com"

Generate SSH Key (replace the email address with your own):

1
$ ssh-keygen -t rsa -C "youremail@example.com"

Then hit Enter continuously (or set your own password), and after completion, a .ssh directory will be created under C:\Users\${userName}\ (in linux it will be under ~/), containing two files: id_rsa and id_rsa.pub.

id_rsa is the private key and must not be disclosed, while id_rsa.pub is the public key that can be shared freely (save it in the SSH Key section of Github/GitLab).

For more operations in Git Bash, you can refer to this article — Git Quick Start Guide .


Open the UE project and click on Source Control in the Unreal Editor.

Select connect to Source Control.

In the pop-up window, choose Git in the Provider option and fill in the absolute path of git.exe in your system in Git Path.
Select Add a .gitignore file, then click initialize project with Git, and finally click Accept Settings to complete the initialization.

Now, you can see a green circle with up and down arrows appearing on Source Control.

At this point, we need to do a commit of our project (which is also a submission of all file changes. Since it’s initialization, we need to submit all files at once). Click on Source Control and select Submit to Source Control.

In the pop-up window, enter the commit message (equivalent to add and commit in git), and then click OK.

The Source Control initialization is complete, and now we can test it.

Create a new blueprint class EmptyActor, just to test writing a node.

Then right-click on this blueprint class in the Content Browser, go to Source Control -> Check In for an initial commit of this blueprint class.

In the pop-up window, fill in the relevant information (commit), then click OK.

Now we can edit the EmptyActor blueprint class again, but we will not submit (don’t check in).

You can use diff to check what changes have been made compared to the last submitted version: right-click on the blueprint class and select Source Control -> Diff Against Depot, and a diff window will pop up. We can see what modifications have been made in that blueprint class.

On the blueprint class right-click -> Source Control, there are the following options: Check In / Refresh / History / Diff Against Depot / Revert, of which the uses of Check In and Diff Against Depot have been mentioned above.

Check In submits the current file.

Refresh refreshes the current file (blueprint class) status.

History views the history of submissions (Check In), and can also provide the differences between the current unsubmitted changes and a certain submitted version.

Diff Against Depot views the differences between the current unsubmitted (Check In) changes and the last submitted version.

Revert discards the current unsubmitted (Check In) changes (which means reverting to the state at the last Check In). Note: After Revert, restarting the engine is required to take effect, which seems to be a bug in UE (4.12.5). The effect of Revert is equivalent to executing git checkout -- ${filename} directly in Git Bash.


The integrated Source Control::Git in UE cannot directly revert to a certain submitted version in the Unreal Editor; in general, the operable functions are still quite limited (the node comparison of blueprints is still quite nice), but you can use Git’s other operations (version rollback/branch management/remote pushing, etc.) in conjunction with Git Bash.

It should be noted that when using Git Bash for version rollback, you must close the Unreal Editor, as the rollback requires modifications to files, and the Unreal Editor currently occupies (opens) that file (blueprint class). Performing a version rollback on a file (blueprint class) that is not occupied (opened) also requires restarting the Unreal Editor to see the rollback effect (the effect will not be seen if not restarted).

When using Git to push (push) and pull (pull) remote branches, you need to execute it in Git Bash. Similarly, you need to close the Unreal Editor. Be sure to edit the .gitignore to ignore unnecessary files to save push/pull time.

The article is finished. If you have any questions, please comment and communicate.

Scan the QR code on WeChat and follow me.

Title:在UE中使用Git进行版本控制
Author:LIPENGZHA
Publish Date:2016/10/07 23:31
World Count:3.7k Words
Link:https://en.imzlp.com/posts/7647/
License: CC BY-NC-SA 4.0
Reprinting of the full article is prohibited.
Your donation will encourage me to keep creating!