Difference between revisions of "Guide to FS Open and git"

From FreeSpace Wiki
Jump to: navigation, search
(Collaboration with remotes: Tortoise Git)
(Collaboration with remotes: Tortoise Git: add pics)
Line 68: Line 68:
 
* committing to that branch and pushing it back to your own repository
 
* committing to that branch and pushing it back to your own repository
  
You may do this when you're collaborating with another developer on a feature prior to it being committed to the master
+
You may do this when you're collaborating on a feature prior to it being committed to the master
  
 
* Start by right clicking on the local repository directory and selecting "Settings"
 
* Start by right clicking on the local repository directory and selecting "Settings"
(piccy)
+
[[File:Git-addremote-1.png]]
 
* Select the "Remote" item from the left hand menu, then
 
* Select the "Remote" item from the left hand menu, then
 
** add a local name for the new remote repository
 
** add a local name for the new remote repository
Line 77: Line 77:
 
** Set the "Tags" dropdown to "None"
 
** Set the "Tags" dropdown to "None"
 
** Click "Add New/Save"
 
** Click "Add New/Save"
(piccy)
+
[[File:Git-addremote-2.png]]
 
* You should be prompted if you want to "...fetch remote branches...", select "Yes"
 
* You should be prompted if you want to "...fetch remote branches...", select "Yes"
(piccy)
+
[[File:Git-addremote-3.png]]
 
* All the defaults should be fine, click "OK"
 
* All the defaults should be fine, click "OK"
(piccy)
+
* Note that this step may take a little time
* This step may take a little time.
+
[[File:Git-addremote-4.png]]
 
* When it's complete you want to create a local branch to track one of the remote repositories branches
 
* When it's complete you want to create a local branch to track one of the remote repositories branches
 
* Right click on the local repository directory and select "Create Branch..."
 
* Right click on the local repository directory and select "Create Branch..."
(piccy)
+
[[File:Git-remotebranch-1.png]]
 
* Set "Base On" -> "Branch" to the remote branch you want to work on
 
* Set "Base On" -> "Branch" to the remote branch you want to work on
 
* Check "Switch to new branch"
 
* Check "Switch to new branch"
 
* Click "OK"
 
* Click "OK"
(piccy)
+
[[File:Git-remotebranch-2.png]]
 
* Write some code!
 
* Write some code!
 
* When you're ready to commit, right click on the local repository directory and select "Git Commit -> (branchname)..."
 
* When you're ready to commit, right click on the local repository directory and select "Git Commit -> (branchname)..."
(piccy)
+
[[File:Git-remotebranch-3.png]]
 
* Enter a commit message
 
* Enter a commit message
 
* Review the changes that will make up the commit by double-clicking on files in the list
 
* Review the changes that will make up the commit by double-clicking on files in the list
(piccy)
+
[[File:Git-remotebranch-4.png]]
* When the commit it completed there will be a button to "Push" your branch.
+
* When the commit is completed there will be a button to "Push" your branch.
 
* You probably won't have permission to push to the other persons remote branch, so push to your own remote repository
 
* You probably won't have permission to push to the other persons remote branch, so push to your own remote repository
* You may want to change the remote branch name (e.g. with a reference to the remote it can from)
+
* Optionally change the remote branch name (e.g. with a reference to the remote it can from)
 
* Select "Origin" as your "Destination" -> "Remote"
 
* Select "Origin" as your "Destination" -> "Remote"
 
* Click "OK"
 
* Click "OK"
(piccy)
+
[[File:Git-remotebranch-5.png]]
 
* Now you can tell the other person that you've added to their branch and have pushed the changes to your own remote branch
 
* Now you can tell the other person that you've added to their branch and have pushed the changes to your own remote branch
 
* They can now follow (most of) the steps above to add your repository as (to them) a remote and fetch/merge your changes into their branch
 
* They can now follow (most of) the steps above to add your repository as (to them) a remote and fetch/merge your changes into their branch
Line 107: Line 107:
 
* Firstly ensure that you have the branch to want to merge into selected
 
* Firstly ensure that you have the branch to want to merge into selected
 
* Right click on the repository directory and select "Fetch..."
 
* Right click on the repository directory and select "Fetch..."
(piccy)
+
[[File:Git-remotebranch-6.png]]
 
* Select the correct remote repository from the dropdown
 
* Select the correct remote repository from the dropdown
(piccy)
+
[[File:Git-remotebranch-7.png]]
 
* Right click on the repository directory and select "Merge..."
 
* Right click on the repository directory and select "Merge..."
(piccy)
+
[[File:Git-remotebranch-8.png]]
 
* Select the correct remote branch to merge from
 
* Select the correct remote branch to merge from
 
* Click OK and you're done (assuming there are no merge conflicts of course...)
 
* Click OK and you're done (assuming there are no merge conflicts of course...)
(piccy)
+
[[File:Git-remotebranch-9.png]]

Revision as of 10:56, 25 February 2014

Getting the source: Tortoise Git

(based on Getting_the_FreeSpace2:_SCP_Source_Code)

  • Download and install Git For Windows (this is a dependency for TortoiseGit)
  • Download and install TortoiseGit (you probably need to reboot after installing)
  • Make a new folder on your HDD where you'd like to install the code. You'll need a fair bit of space for the code + the intermediate files when building it. Press right mouse and choose Git Clone from the list.

Git-clone-1.png

Git-clone-2.png

  • Press OK to begin downloading from the repository (this may take a few minutes, depending on the speed of your internet connection)


Simple Development: Tortoise Git

Note: the guide assumes that you will be developing using a github fork (which is recommended for everyone, SCP members and non-members alike)

Github-fork.png

  • Record the URL for your newly forked copy of the FSO repository

Github-fork-2.png

  • Get the code per the guide above (fix with proper intra-page link)
    • Note: you need to use the URL for your forked repository, not the main FSO repository listed above
  • Right click on the repository directory and select TortoiseGit -> Create Branch
    • Note: all development should be done in a new branch, instead of being done in the "master" branch. It's just simpler

Git-branch-1.png

  • In the new window, enter the name for the new branch, verify that the branch is based on HEAD (master) and check the "Switch to new branch" box

Git-branch-2.png

  • Write some code with your Editor of Choice
  • Test your new code
  • When you're happy with the code, right click on the repository directory and select TortoiseGit -> Diff

Git-commit-1.png

  • Review your changes by double-clicking on all the files listed in the new window (ensure no unwanted changes have snuck in!).

Git-commit-2.png

  • This is how the diff will be displayed (using TortoiseGitMerge, which is also used to resolve conflicts)

Git-commit-3.png

  • When your review is complete, press "Commit" (in the same window that you double clicked on all the changed files)
  • In the new window, add a commit message and press OK

Git-commit-4.png

  • When the commit is complete, press the "push" button to send your commit(s) to your github repository

Git-commit-5.png

  • Select your local branch name from the drop down list and ensure your Destination -> Remote: is "origin"
  • If you want to, you can give the public remote branch a different name to your local branch (this can be useful when rebasing a branch already published to your public repository)
  • Finally, press OK

Git-commit-6.png

  • Go to your Github Repository webpage and select the branch you just pushed

Git-commit-7.png

  • When you have the correct branch selected, click on the "Pull/Review/Compare" button

Git-commit-8.png

  • Now click on "Create Pull Request"

Git-commit-9.png

  • Note: the previous three steps can be done as a single step if you have recently pushed a branch by selecting the "Compare and Pull Request" button
  • Add comments to the pull request if you wish, then click "Send Pull Request"

Git-commit-10.png

  • And that's it! Now you wait for the pull request to be reviewed and committed to primary FSO master branch

Syncing and Simple Conflict Resolution: Tortoise Git

TBA

Collaboration with remotes: Tortoise Git

Here we'll go through:

  • adding a remote branch from someone else's repository
  • committing to that branch and pushing it back to your own repository

You may do this when you're collaborating on a feature prior to it being committed to the master

  • Start by right clicking on the local repository directory and selecting "Settings"

Git-addremote-1.png

  • Select the "Remote" item from the left hand menu, then
    • add a local name for the new remote repository
    • add the remote repository URL (I'm using m!m's github repository in this example)
    • Set the "Tags" dropdown to "None"
    • Click "Add New/Save"

Git-addremote-2.png

  • You should be prompted if you want to "...fetch remote branches...", select "Yes"

Git-addremote-3.png

  • All the defaults should be fine, click "OK"
  • Note that this step may take a little time

Git-addremote-4.png

  • When it's complete you want to create a local branch to track one of the remote repositories branches
  • Right click on the local repository directory and select "Create Branch..."

Git-remotebranch-1.png

  • Set "Base On" -> "Branch" to the remote branch you want to work on
  • Check "Switch to new branch"
  • Click "OK"

Git-remotebranch-2.png

  • Write some code!
  • When you're ready to commit, right click on the local repository directory and select "Git Commit -> (branchname)..."

Git-remotebranch-3.png

  • Enter a commit message
  • Review the changes that will make up the commit by double-clicking on files in the list

Git-remotebranch-4.png

  • When the commit is completed there will be a button to "Push" your branch.
  • You probably won't have permission to push to the other persons remote branch, so push to your own remote repository
  • Optionally change the remote branch name (e.g. with a reference to the remote it can from)
  • Select "Origin" as your "Destination" -> "Remote"
  • Click "OK"

Git-remotebranch-5.png

  • Now you can tell the other person that you've added to their branch and have pushed the changes to your own remote branch
  • They can now follow (most of) the steps above to add your repository as (to them) a remote and fetch/merge your changes into their branch
  • When that happens you probably want to get their changes into your local branch
  • Firstly ensure that you have the branch to want to merge into selected
  • Right click on the repository directory and select "Fetch..."

Git-remotebranch-6.png

  • Select the correct remote repository from the dropdown

Git-remotebranch-7.png

  • Right click on the repository directory and select "Merge..."

Git-remotebranch-8.png

  • Select the correct remote branch to merge from
  • Click OK and you're done (assuming there are no merge conflicts of course...)

Git-remotebranch-9.png