Graygzou
5/26/2018 - 5:25 PM

GitHub : Personal memo and best practices

Personal memo for GitHub features / Best practices.

Cheat Sheet GitHub

Git LFS

Git can work fine with 3D games out of the box. However the main caveat here is that versioning large (>5 MB) media files can be a problem over the long term as your commit history bloats. Maybe use DropBox for art assets.

Regular Branching

  • Development branch (also called ‘develop’) : This is your main development branch where all the others branches (e.g. feature branches) will be merging into this branch.
  • Production branch (also called ‘master’) : This branch represents the latest released / deployed codebase. Only updated by merging other branches into it.
  • Feature branches (also prefixed with ‘feature/’) : When you start work on anything non-trivial, you create a feature branch. When finished, you’ll merge this branch back into the development branch.
  • Release branches (also prefixed with ‘release/’) : When you’re about to package a new release, you create a release branch from the development branch. You can commit to it during your preparation for a release, and when it’s ready to be deployed, you merge it into both the development branch and the master branch.
  • Hotfix branches (also prefixed with ‘hotfix/’) : If you need to patch the latest release without picking up new features from the development branch, you can create a hotfix branch from the latest deployed code in master. Once you’ve made your changes, the hotfix branch is then merged back into both the master branch and the development branch.

Unity Project : Github Settings

For versions of Unity 3D v4.3 and up:

  • (Skip this step in v4.5 and up) Enable External option in Unity → Preferences → Packages → Repository.
  • Open the Edit menu and pick Project Settings → Editor:
    • Switch Version Control Mode to Visible Meta Files.
    • Switch Asset Serialization Mode to Force Text. (By default already)
  • Save the scene and project from File menu.

Unreal Project : Github Settings

TODO

Acknowledgements

Based on the following blog posts :

Useful commands

Clone the central repository

git clone https://user@host/path/to/repo.git

  • Explanation(s): When you clone a repository, Git automatically adds a shortcut called origin that points back to the “parent” repository.

Create a branch

git checkout develop

git branch sprint-X/feature-1

git push --set-upstream origin sprint-X/feature-1

Rebase (instead of merge commit)

git pull --rebase origin master

  • Explanation(s): Rebasing allow to keep a cleaner history for a repository.
  • Warning: Use rebase only if the changes do not deserve a separate branch.

git rebase --abort

  • Explanation(s): Cancel a current rebase.

Merge branches (instead of rebasing)

git merge origin/develop

Checkout a branch

git fetch origin

git checkout sprint-X/feature-1

Commiting (and pushing)

git status

git diff "Folder/feature-1/script.cs"

git add . --all