Difference between revisions of "Setting up an Online Repository"

From Frictional Wiki
Jump to navigation Jump to search
m
Line 1: Line 1:
{{wip}}
 
 
 
This article describes the process of setting up an online Git repository, and discusses the workflow.
 
This article describes the process of setting up an online Git repository, and discusses the workflow.
  
Line 9: Line 7:
  
 
[[File:Git-branch-demonstration.png|alt=|thumb|Git branches are useful to separate your version from the rest of the main project version, and later be merged when your work is done.]]
 
[[File:Git-branch-demonstration.png|alt=|thumb|Git branches are useful to separate your version from the rest of the main project version, and later be merged when your work is done.]]
 +
 
*<u>Commit</u> - A snapshot of the project. Its purpose is to allow to revert unwanted changes and any accidents (such as deleting something). On the graph below, individual dots are commits.
 
*<u>Commit</u> - A snapshot of the project. Its purpose is to allow to revert unwanted changes and any accidents (such as deleting something). On the graph below, individual dots are commits.
 
*<u>Repository</u> - The service that stores each commit; it is often used as a substitute for the folder which holds the project.
 
*<u>Repository</u> - The service that stores each commit; it is often used as a substitute for the folder which holds the project.
Line 15: Line 14:
 
*<u>Tip</u> - is the latest commit in a branch
 
*<u>Tip</u> - is the latest commit in a branch
 
*<u>Pull</u> - "Download" commits from the branch in the repository. You pull in order to update the project on your end.
 
*<u>Pull</u> - "Download" commits from the branch in the repository. You pull in order to update the project on your end.
*<u>Push</u> - "Upload" your local commits to th repository. You push in order to update the project on the repository.
+
*<u>Push</u> - "Upload" your local commits to the repository. You push in order to update the project on the repository.
 
 
<br />
 
  
 
==Getting Started==
 
==Getting Started==
In this guide, the following applications and services are used:
+
In this article, the following applications and services are used:
  
 
*Git
 
*Git
Line 26: Line 23:
 
*GitKraken
 
*GitKraken
  
First, it is necessary to install Git on our local machine and later set up the local and online repository.
+
It is necessary to install Git and GitKraken on our local machine and later set up the local and online repository.
  
 
#[https://git-scm.com/ Download and install Git].
 
#[https://git-scm.com/ Download and install Git].
Line 32: Line 29:
 
#[https://gitlab.com/ Register a free account at GitLab]
 
#[https://gitlab.com/ Register a free account at GitLab]
 
#Before you can properly use the online git functions, you will need to generate an SSH key and add it to your gitlab account. [https://git-scm.com/book/en/v2/Git-on-the-Server-Generating-Your-SSH-Public-Key Here's a guide].
 
#Before you can properly use the online git functions, you will need to generate an SSH key and add it to your gitlab account. [https://git-scm.com/book/en/v2/Git-on-the-Server-Generating-Your-SSH-Public-Key Here's a guide].
 +
#[https://www.gitkraken.com/ Download and install GitKraken Git GUI]
  
 
+
==Creating the Project on GitLab==
{{Todo|Add git-kraken stuff}}
 
 
 
==Creating the Project==
 
  
 
#In your dashboard, click the green '''New project''' button or use the plus icon in the navigation bar. This opens the '''New project''' page.
 
#In your dashboard, click the green '''New project''' button or use the plus icon in the navigation bar. This opens the '''New project''' page.
 
#On the New project page, choose '''blank project.'''
 
#On the New project page, choose '''blank project.'''
#On th '''Blank project''' tab, provide the following information:
+
#On the '''Blank project''' tab, provide the following information:
 
#*The name of your project in the '''Project name''' field. When adding the name, the '''Project slug''' will auto populate. The slug is what the GitLab instance will use as the URL path to the project. If you want a different slug, input the project name first, then change the slug after.
 
#*The name of your project in the '''Project name''' field. When adding the name, the '''Project slug''' will auto populate. The slug is what the GitLab instance will use as the URL path to the project. If you want a different slug, input the project name first, then change the slug after.
 
#*The '''Project description (optional)''' field enables you to enter a description for your project’s dashboard, which will help others understand what your project is about. Though it’s not required, it’s a good idea to fill this in.
 
#*The '''Project description (optional)''' field enables you to enter a description for your project’s dashboard, which will help others understand what your project is about. Though it’s not required, it’s a good idea to fill this in.
Line 46: Line 41:
 
#*(Optional) Selecting the Initialize repository with a README option creates a README file so that the Git repository is initialized, has a default branch, and can be cloned.
 
#*(Optional) Selecting the Initialize repository with a README option creates a README file so that the Git repository is initialized, has a default branch, and can be cloned.
 
#Click '''Create project.'''
 
#Click '''Create project.'''
{{note|Usually, you may want to initialize your project with a '''README''' file, but if you already have an existing mod folder you want to push to git, do not initialize your project with a '''README''' file. Save the project and follow the instructions inside for '''pushing an existing folder'''.}}
+
{{note|Usually, you may want to initialize your project with a '''README''' file, but if you already have an existing mod folder you want to push to git, do not initialize your project with a '''README''' file. Save the project and follow the instructions inside for '''pushing an existing folder'''.}}<br />
 +
 
 +
== Setting up GitKraken ==
 +
 
 +
# Open GitKraken.
 +
# Go to '''File->Preferences->Authentication'''.
 +
# Select '''GitLab''' and click on '''Connect to GitLab'''.
 +
# Approve the connection.
 +
 
 +
== Cloning the Project using GitKraken ==
 +
 
 +
# Open a new tab if there isn't one open already, and click on '''Clone a Repo''' and then '''GitLab'''
 +
# In '''Where to clone to, n'''avigate to the directory in which you want to place the mod folder at.
 +
# Select the '''Repository to clone''' and click on '''Clone the repo!'''
 +
# Wait until the files are copied. When it's done, a prompt will show up to open the repo in the app - click on it to open the repository window.
 +
# You can now create branches, commit, pull and push your changes via GItKraken!
  
==Cloning the Project==
+
==Cloning the Project using Command Line==
  
 
#Navigate to the directory in which you want to place the mod folder at.
 
#Navigate to the directory in which you want to place the mod folder at.
 
#Inside the folder, right click and click on "Git bash here".
 
#Inside the folder, right click and click on "Git bash here".
#Copy and paste the following command (right click because Ctrl+C doesn't work in Bash):<syntaxhighlight lang="bash">
+
#Copy and paste the following command (right click because Ctrl+C doesn't work in Bash):
git clone git@gitlab.com:MyRepository.git FolderName
 
</syntaxhighlight>
 
  
 
==Creating a Remote==
 
==Creating a Remote==
Line 64: Line 72:
 
git remote add origin git@gitlab.com:MyRepository.git
 
git remote add origin git@gitlab.com:MyRepository.git
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
 +
== See Also ==
 +
[https://www.youtube.com/watch?v=HVsySz-h9r4 Git Tutorial: Command-line Fundamentals]
 +
 +
[https://www.youtube.com/watch?v=ub9GfRziCtU GitKraken Tutorial For Beginners]
 
[[Category:Modding]]
 
[[Category:Modding]]

Revision as of 21:19, 28 July 2020

This article describes the process of setting up an online Git repository, and discusses the workflow.

Why do I Need a Repository?

The biggest benefit is to combine changes made by all members of the mod team into a single "current" copy. If you're working on a mod by yourself, you probably don't need an online repository. However, an offline one will still give you many other benefits, which online repositories also provide. If you break something, you can easily compare to the previous version (or rollback to it), and easily keep track of exactly what things you've changed since the previous version. Also, if valve update the source code, a repository can make the task of merging the two versions of the code considerably easier.

Terminology

Git branches are useful to separate your version from the rest of the main project version, and later be merged when your work is done.
  • Commit - A snapshot of the project. Its purpose is to allow to revert unwanted changes and any accidents (such as deleting something). On the graph below, individual dots are commits.
  • Repository - The service that stores each commit; it is often used as a substitute for the folder which holds the project.
  • Branch - A separate chain of commits; think of it as making your own version of the project, while others make their own ones.
  • Master Branch - The mutual version of the project; every now and then you (or the project manager) will need to merge your version with the "official" (master) one. This will create a new commit. However, before branches can be merged, you will need to push (upload) your changes to the online repository. You should also make it a habit to pull (download) from the master branch before starting any work. On the picture below you can see the master branch (blue), and a side branch (green, "Feature").
  • Tip - is the latest commit in a branch
  • Pull - "Download" commits from the branch in the repository. You pull in order to update the project on your end.
  • Push - "Upload" your local commits to the repository. You push in order to update the project on the repository.

Getting Started

In this article, the following applications and services are used:

  • Git
  • GitLab
  • GitKraken

It is necessary to install Git and GitKraken on our local machine and later set up the local and online repository.

  1. Download and install Git.
  2. First-time Git Setup - "Your Identity" is the important part of the article. This step is still optional, but will resolve headaches later.
  3. Register a free account at GitLab
  4. Before you can properly use the online git functions, you will need to generate an SSH key and add it to your gitlab account. Here's a guide.
  5. Download and install GitKraken Git GUI

Creating the Project on GitLab

  1. In your dashboard, click the green New project button or use the plus icon in the navigation bar. This opens the New project page.
  2. On the New project page, choose blank project.
  3. On the Blank project tab, provide the following information:
    • The name of your project in the Project name field. When adding the name, the Project slug will auto populate. The slug is what the GitLab instance will use as the URL path to the project. If you want a different slug, input the project name first, then change the slug after.
    • The Project description (optional) field enables you to enter a description for your project’s dashboard, which will help others understand what your project is about. Though it’s not required, it’s a good idea to fill this in.
    • Changing the Visibility Level modifies the project’s viewing and access rights for users.
    • (Optional) Selecting the Initialize repository with a README option creates a README file so that the Git repository is initialized, has a default branch, and can be cloned.
  4. Click Create project.
Note icon.png Usually, you may want to initialize your project with a README file, but if you already have an existing mod folder you want to push to git, do not initialize your project with a README file. Save the project and follow the instructions inside for pushing an existing folder.


Setting up GitKraken

  1. Open GitKraken.
  2. Go to File->Preferences->Authentication.
  3. Select GitLab and click on Connect to GitLab.
  4. Approve the connection.

Cloning the Project using GitKraken

  1. Open a new tab if there isn't one open already, and click on Clone a Repo and then GitLab
  2. In Where to clone to, navigate to the directory in which you want to place the mod folder at.
  3. Select the Repository to clone and click on Clone the repo!
  4. Wait until the files are copied. When it's done, a prompt will show up to open the repo in the app - click on it to open the repository window.
  5. You can now create branches, commit, pull and push your changes via GItKraken!

Cloning the Project using Command Line

  1. Navigate to the directory in which you want to place the mod folder at.
  2. Inside the folder, right click and click on "Git bash here".
  3. Copy and paste the following command (right click because Ctrl+C doesn't work in Bash):

Creating a Remote

This is an additional step to make the git workflow a little bit easier.

To make the process of downloading/uploading easier, a remote can be created; it's a shortcut which replaces the lengthy repository URL with a short acronym; generally speaking, a common name for a remote is origin, but it can be called in any name. The command is:

git remote add <remote_name> <remote_repo_url>

Usage example:

git remote add origin git@gitlab.com:MyRepository.git

See Also

Git Tutorial: Command-line Fundamentals

GitKraken Tutorial For Beginners