Skip to content

Commit 99c1846

Browse files
committed
added more generalized git basics doc
1 parent 32091ad commit 99c1846

File tree

3 files changed

+165
-94
lines changed

3 files changed

+165
-94
lines changed

README.md

+2-94
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,3 @@
1-
## Setting Up
1+
[git basics for other](./basic_git.md)
22

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)

basic_git.md

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
## Setting Up
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_GitHub`
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 and do your work locally in it
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+
`git branch` -> shows you which branch you're currently working in
29+
30+
### 4. Check your changes; determine out what you want to include in the commit
31+
`git status` -> will show all files changed
32+
`git diff` -> will show specific lines changed
33+
34+
### 5. Add and commit your changes within your development/feature branch
35+
`git add specific_files` or `git add .` (for all files) -> select files to include
36+
`git commit -m 'your_message_in_here'` -> to include a helpful message with your commit
37+
(if you make a mistake, you can `git reset HEAD~` to revert)
38+
39+
### 6. Push changes from your local development branch up to share with others/for review to merge in
40+
`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
41+
42+
### 7. Submit Pull Requests for other people to review; if approved, merge into `master` branch via GitHub site
43+
44+
45+
## Handling Potential Merge Conflicts
46+
If there are merge conflicts, GitHub will not let you merge via the site before handling them. Hopefully this will not happen. If it does:
47+
* `git pull origin master` (pulls in the latest changes from master)
48+
* `git status` -> will show any merge conflicts (specifically, the files that'll need to be resolved)
49+
* Open the files in your selected text editor (MonoDevelop/Sublime/etc.) to intelligibly determine which changes to keep and what lines to remove.
50+
51+
Then, add/commit/push your new commits:
52+
* `git add .`
53+
* `git commit -m "your commit message"`
54+
* `git push origin target_branch`
55+
56+
57+
## Miscellaneous Commands (that you probably don't need but may be useful)
58+
59+
### Deleting an old local branch
60+
`git branch -D your_branch_name` -> to delete old branches no longer in use (this isn't really necessary)
61+
62+
### Rebasing
63+
`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.
64+
65+
### Stashing (and Applying) Changes
66+
This is useful for many things! Oftentimes I use this for temporarily saving my changes, merging in new changes that other people have made, then applying my changes atop those merged in changes. There are more complex and powerful use cases than this though!
67+
`git stash` -> temporarily saves your changes and reverts your working directory to match the HEAD commit
68+
`git stash apply` -> re-applies those changes

games_git.md

+95
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
## Setting Up
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.

0 commit comments

Comments
 (0)