cd your_file_location
(this will create the directory inside of the directory you navigated to in step #1)
git clone [the link from GH]
When starting a new feature:
git branch
-> lists all branches you're tracking locally, with an asterisk by the branch you're on
git checkout master
-> switches to master
branch
git pull origin master
-> pulls all commits from remote master
branch into the branch you are currently on
(in this case, into master
branch)
git checkout -b your_feature_branch_name
-> creates new branch from current branch (with commits from current branch)
Also:
git checkout other_branch_name
-> switches from your current branch to another branch
If you open the directory you're in from "On Disk", it should just be using the contents of the branch you're on.
If you're not sure what branch you are working on, check with git branch
.
If you are working on a bigger change that is not solely to styling:
- Create a new test scene with all the objects copied over from the main scene.
- After handling any errors in that test scene, you might want to place any new objects from that test scene into a prefab.
If you are working on a minor style change:
- Feel free to make the changes directly in the main scene, add, commit, and push up changes.
- Then open the PR and just merge it in (no review needed unless you anticipate a conflict).
git status
-> will show all files changed
git diff
-> will show specific lines changed
git add specific_files
or git add .
(for all files) -> select files to include
git commit -m 'your_message_in_here'
-> to include a helpful message with your commit
(if you make a mistake, you can git reset HEAD~
)
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
Integrate the test scene/prefabs that are working into the main scene on master, and push up.
- Follow the flow above to do this in a separate commit/PR, directly into the main scene.
git fetch
-> will retrieve all remote tracking branches from GitHub
git checkout someone_elses_branch
-> checkout someone else's branch from GitHub that now has been fetched
This should've auto-updated to the contents on the branch you've checked out.
git push origin someone_elses_branch
Hopefully this will not happen (if we use test scenes/prefabs mostly)... if it does happen:
- (while on
someone_elses_branch
) ->git pull origin master
(pulls in the latest changes from master) git status
-> will show any merge conflicts (specifically, the files that'll need to be resolved)- Open the files in your selected text editor (MonoDevelop/Sublime/etc.) or open Unity to intelligibly determine which changes to keep and what lines to remove.
Then, just add/commit/push your new commits and notify the PR author:
git add .
git commit -m "your commit message"
git push origin someone_elses_branch
git branch -D your_branch_name
-> to delete old branches no longer in use (this isn't really necessary)
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.