cd your_file_location
(this will create the directory inside of the directory you navigated to in step #1)
git clone the_link_from_GitHub
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)
Related:
git checkout other_branch_name
-> switches from your current branch to another branchgit branch
-> shows you which branch you're currently working in
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~
to revert)
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
7. Submit Pull Requests for other people to review; if approved, merge into master
branch via GitHub site
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:
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.) to intelligibly determine which changes to keep and what lines to remove.
Then, add/commit/push your new commits:
git add .
git commit -m "your commit message"
git push origin target_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.
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!
git stash
-> temporarily saves your changes and reverts your working directory to match the HEAD commit
git stash apply
-> re-applies those changes