git checkout -b branch_name //create new local branch
git push -u origin branch_name //push the local branch to origin
```
- commit
```
git commit -a //commit all change files
git checkout -- *file* //revert changes made to that file
git reset head //reset all to the last commit (--hard to force)
```
- stash changes
```
git stash
git stash --apply
```
- undo last local commit
```
git reset [--hard] HEAD~
```
## Submodules
- Create a submodule
```
git submodule add https://github.com/name/repo
```
- Update submodule: If there's a new commit on a submodule that you want to have in boardcore:
```
git submodule sync
git submodule update --remote --init
git commit
```
- Update miosix-kernel fork: If you want to pull in skyward-er/miosix-kernel the commits that were made in the original repo (fedetft/miosix-kernel), you have to do two things:
* Clone skyward-er/miosix-kernel and in it:
```
git fetch upstream
git merge upstream/testing
git push
```
* In skyward-boarcore:
```
git checkout testing
git submodule update --remote
git commit
git push
```
- Push commits from within submodule: In general, if you want to modify a submodule (e.g. modifiy mavlink_skyward_lib from Mavlink_editor or skyward-boardcore).
```
cd submodule-folder
git checkout master
git pull
<modifiy>
git add <file-modified>
git commit // commit updates inside the submodule
git push
cd ../..
git submodule update // the submodule folder now points to latest version
git commit // commit the update of the submodule reference