|
1 |
| -## Setting Up |
| 1 | +[git basics for other](./basic_git.md) |
2 | 2 |
|
3 |
| -### 1. Navigate to where you want to put your local repository |
4 |
| -`cd your_file_location` |
5 |
| - |
6 |
| -### 2. Clone the repository |
7 |
| -(this will create the directory inside of the directory you navigated to in step #1) |
8 |
| -`git clone [the link from GH]` |
9 |
| - |
10 |
| -### 3. Start the flow below! :) |
11 |
| - |
12 |
| - |
13 |
| -## Git Flow & Git Basics |
14 |
| - |
15 |
| -When starting a new feature: |
16 |
| -### 1. Start from the `master` branch |
17 |
| -`git branch` -> lists all branches you're tracking locally, with an asterisk by the branch you're on |
18 |
| -`git checkout master` -> switches to `master` branch |
19 |
| - |
20 |
| -### 2. Pull in the latest merged changes from the remote tracking branch on GitHub |
21 |
| -`git pull origin master` -> pulls all commits from remote `master` branch into the branch you are currently on |
22 |
| -(in this case, into `master` branch) |
23 |
| - |
24 |
| -### 3. From the `master` branch, checkout a new feature branch |
25 |
| -`git checkout -b your_feature_branch_name` -> creates new branch from current branch (with commits from current branch) |
26 |
| -Also: |
27 |
| -`git checkout other_branch_name` -> switches from your current branch to another branch |
28 |
| - |
29 |
| -### 4. Do your work in Unity in a Test Scene/Using Prefabs |
30 |
| -If you open the directory you're in from "On Disk", it _should_ just be using the contents of the branch you're on. |
31 |
| -If you're not sure what branch you are working on, check with `git branch`. |
32 |
| - |
33 |
| -If you are working on a bigger change that is not solely to styling: |
34 |
| -* Create a new test scene with all the objects copied over from the main scene. |
35 |
| -* After handling any errors in that test scene, you might want to place any new objects from that test scene into a prefab. |
36 |
| - |
37 |
| -If you are working on a minor style change: |
38 |
| -* Feel free to make the changes directly in the main scene, add, commit, and push up changes. |
39 |
| -* Then open the PR and just merge it in (no review needed unless you anticipate a conflict). |
40 |
| - |
41 |
| -### 5. Check your changes; determine out what you want to include in the commit |
42 |
| -`git status` -> will show all files changed |
43 |
| -`git diff` -> will show specific lines changed |
44 |
| - |
45 |
| -### 5. Add and commit your changes within your development/feature branch |
46 |
| -`git add specific_files` or `git add .` (for all files) -> select files to include |
47 |
| -`git commit -m 'your_message_in_here'` -> to include a helpful message with your commit |
48 |
| -(if you make a mistake, you can `git reset HEAD~`) |
49 |
| - |
50 |
| -### 6. Push changes from your local development branch up to share with others/for review to merge in |
51 |
| -`git push origin your_feature_branch_name` -> pushes whatever changes you've saved locally in this branch to your remote tracking branch on GitHub with the same name |
52 |
| - |
53 |
| -### 7. Submit Pull Requests for other people to review, merge into `master` branch via GitHub site |
54 |
| - |
55 |
| -### 8. After Test Scene and/or Prefabs are merged into master |
56 |
| -Integrate the test scene/prefabs that are working into the main scene on master, and push up. |
57 |
| -* Follow the flow above to do this in a separate commit/PR, directly into the main scene. |
58 |
| - |
59 |
| - |
60 |
| -## Reviewing Code and Handling Potential Merge Conflicts |
61 |
| - |
62 |
| -### 1. Retrieve all remote branches |
63 |
| -`git fetch` -> will retrieve all remote tracking branches from GitHub |
64 |
| - |
65 |
| -### 2. Switch to target branch to review |
66 |
| -`git checkout someone_elses_branch` -> checkout someone else's branch from GitHub that now has been fetched |
67 |
| - |
68 |
| -### 3. Check out the new features/issues in Unity! |
69 |
| -This should've auto-updated to the contents on the branch you've checked out. |
70 |
| - |
71 |
| -### 4. Comment on the PR if there was one, or on Slack if there was not a PR opened yet |
72 |
| - |
73 |
| -### 5. (Optional) Make, commit, and push changes to `someone_elses_branch` |
74 |
| -`git push origin someone_elses_branch` |
75 |
| - |
76 |
| -### 6. If there are merge conflicts, GitHub will not let you merge via the site before handling them. |
77 |
| -Hopefully this will not happen (if we use test scenes/prefabs mostly)... if it _does_ happen: |
78 |
| -* (while on `someone_elses_branch`) -> `git pull origin master` (pulls in the latest changes from master) |
79 |
| -* `git status` -> will show any merge conflicts (specifically, the files that'll need to be resolved) |
80 |
| -* Open the files in your selected text editor (MonoDevelop/Sublime/etc.) or open Unity to intelligibly |
81 |
| -determine which changes to keep and what lines to remove. |
82 |
| - |
83 |
| -Then, just add/commit/push your new commits and notify the PR author: |
84 |
| -* `git add .` |
85 |
| -* `git commit -m "your commit message"` |
86 |
| -* `git push origin someone_elses_branch` |
87 |
| - |
88 |
| - |
89 |
| -## Miscellaneous Commands (that you probably don't need but may be useful) |
90 |
| - |
91 |
| -### Deleting an old local branch |
92 |
| -`git branch -D your_branch_name` -> to delete old branches no longer in use (this isn't really necessary) |
93 |
| - |
94 |
| -### Rebasing |
95 |
| -`git rebase -i HEAD~` -> an example of this command... rebasing can be used to clean up your git commit history, squash multiple commits together, skip select commits, reword your commit message, etc. |
| 3 | +[git basics for games](./games_git.md) |
0 commit comments