I made an plugin for our loved Unreal Engine 4 Editor. As some of you know, Unreal has great Source control features, and in the 4.9 release, they added Git source control support (which is still beta, but works fine!). So, with that, adding and commiting assets works pretty fine, but to push the commits onto your preferred Git server, you need to use the normal Windows cmd / some other Git GUI tools. I thought it would be better to have the functionality ready-to-use in the UnrealEd. So I made a plugin for that! Let’s call it GitPush.
However, this needs some things you need to know first:
- You obviously need a git.exe binary, but I bet you have that already
- The path to this binary needs to be in Windows’ PATH environment variable (A simple test to see if thats working is to open up a new cmd and type in ‘git’. If it shows you help on the command, everything is fine, if not, you need to put the path to git.exe in the environment variable (simple explanation below!))
- Your projects needs to have a git repo already set up (if not the plugin shows you hints just FYI)
- The plugin only supports Git connections via SSH, but that shouldn’t be a problem
- If you change something to the git information (e.g. creating / changing branches, adding / removing remote hosts) you need to restart the editor so GitPush recognizes the changes
If you have a repo set up, with a master branch and remote server, you can use GitPush! Once in the editor, just click on the new button in the Viewport Toolbar. From there, go to the branch you want to push to, and then the remote host server you want to push to. (Note: Unreals Source control feature commits things on the master branch, however, if you select another branch to push to, it just copies the commit from the master to the selected branch).
A simple workthrough on how to create and initialize the Git connection between a service (in this case GitHub) and Unreal:
- Make sure you have a SSH-key linked to your computer with your GitHub profile (click here for more information)
- Make also sure that you enabled Source control in the engine and filled out the nessecary information (more info)
- Create a new repo at GitHub
- Copy the SSH adress by choosing “SSH” in the drop-down above the file list (should read “HTTPS” before)
- In your project folder, open up a new command prompt window and type in git init. This initializes the project folder to be a local git folder.
- Pull all files from your created Git repo (should be empty, maybe it contains a README.MD) with git pull yourCopiedSSHadress. When you did step 1 right, it should download files from the repo your local folder should now contain the files from the repo + all your Unreal files.
- You can test whether git sees all new files by typing in git status. This should show you all files which are not in the repo (so all your Unreal project files).
- Now, you have the repo in your folder (the important part is the .git folder in your project folder), and my plugin sees the branch “master”, because thats the default one, but it will tell you that you don’t have any remote host. The remote host is the server you upload new changes to, and thats obviously GitHub aswell.
- Back in the command prompt, type in git remote add someName yourCopiedSSHadress. In most cases we use “origin” as the remote name and this remote host will be the repo’s SSH adress.
- This shouldn’t return anything… You can check if the host is there by using git remote. This should list you the host you created.
- Now, just (re)start the Editor and hit the GitPush button. You should now see the master branch in the dropdown, and when you select that you should see the remote host’s name. Clicking the hostname will then push files to the repo, if there are files to push, obviously.
If you have questions, bugs, or anything else, feel free to comment them here
I hoped I helped some devs to do their work more efficient
Have a nice day