-
Notifications
You must be signed in to change notification settings - Fork 1
git cmds for preparing for a PR
Background Git meta info
To use your forked repo, it needs to cloned to a local instance (copy). You can do it in with Windows GitHub (or other tools). However if you expect to make contributions back to the original repos (github.com/EnviroDIY/ModularSensors) I've found the cmd line to be most flexible.
For Windows this seems to be GitBash - so make sure you have GitBash and have a secure connection with github using SSH.
There are other ways, and if they are easier - please drop me a note - or write it up and drop me a pointer of what is easier.
#For every new GitBash window - Enable ssh-agent - not needed for Ubuntu/Linux
$ssh-add ~/.ssh/<your_file>_rsa #may require pwd if setup
Login into github
Go to repo to fork eg https://github.com/EnviroDIY/ModularSensors
On top right - press button that says 'Fork' and now it will create a repo in your account - wonderful magic - so for me it creates it in
https://github.com/neilh10/ModularSensors
Plan for your workflow with local repos - I find it useful when comparing, updating and merging back to the original ModularSensors to create
clone of EnviroDIY/ModularSensors at ~/git/envirodiy3/ModularSensors
clone of yourName/ModularSensors at ~/git/envirodiynh/ModularSensors
working copy of ModularSensors at ~/Documents/Arduino/env03/ModularSensors
I usually give then an identifying extra characteristic - number or rev level.
In the above the '~' is linux represenation for the base of your account tree.
That is something like "C:\Users\userName".
So when an File Explorer is brought up - it starts in C:\Users\userName.
Similarly when GitBash cmd window starts - its starts at ~.
Windows and linux use \ and / - sometimes they are interchangeable, and sometimes they aren't.
Bring up a GitBash cmd window and start typing -everything except the $
$cd git
$mkdir envirodiy3
$cd envirodiy3
$git clone git@github.com:EnviroDIY/ModularSensors.git
$cd ModularSensors
github.com:EnviroDIY/ModularSensors has software branch called 'develop'
$git checkout develop
MINGW64 ~/git/envirodiy3/ModularSensors (develop)
This sets your code environment to github.com:EnviroDIY/ModularSensors - think of it as read-only.
Don't make changes here, unless you are prepared to throw them away every time a new update happens on github.com:EnviroDIY/ModularSensors.
Make changes on your own repo - or at the very least create a local branch, and make your changes on that. This will allow you to merge in changes.
$git log -1 #list of last submissions including commit "magic number"
commit d6dec1e184005dd2732f8d14071d98d0cd9146d4 (HEAD -> develop, origin/develop)
Author: Sara
Date: Tue Oct 30 12:52:07 2018 -0400
Removed extra 2-minute logging at start-up
In platformio.ini you can use
https://github.com/EnviroDIY/ModularSensors#d6dec1e184005dd2732f8d14071d98d0cd9146d4
or
https://github.com/EnviroDIY/ModularSensors#develop
#Similar to above, but its a copy of your repo. I use it as a reference in MeldMerge. I use it to merge changes from upstream github.com/EnviroDIY/ModularSensors to local github.com:neilh10/ModularSensors and then push them back onto the net
$cd git
$mkdir envirodiynh
$git clone git@github.com:neilh10/ModularSensors.git
$ cd ModularSensors
$ git checkout develop #local repo by ensure its same as remote git@github.com:neilh10/ModularSensors.git
MINGW64 ~/git/envirodiynh/ModularSensors (develop)
#first time
$git remote add upstream git@github.com:EnviroDIY/ModularSensors.git
$git remote -v
list of origin sources
$git fetch upstream
$git checkout develop
$git merge upstream/develop
#in your Arduino tree, for code to be branched and compiled by your choice of tools
$cd "C:\Users\userName\Documents\Arduino"
#first time
$mkdir env03
$git clone git@github.com:neilh10/ModularSensors.git
$cd ModularSensors
#to get here in new Git Bash shell
$cd "C:\Users\userName\Documents\Arduino\env03\ModularSensors"
$git remote -v
#list of origin sources
$git log -3
#compare in whatever way you want that the two are similar.
meld ~/git/envirodiy3/ModularSensors ~/Documents/Arduino/env03/ModularSensors
#create your work flow branches - branches are quick and low cost, always create for your own work, and when ever you want to check someone else work. Look at git cmds for merge and stash.
#I use some form of unique 'XX' id as well, to be able to make variations
$git checkout -b workXX_nanolevel
make your changes
$git status #see your changes
$git add .
$git commit -m "your comment eg blue moon on a sunday afternoon"
$git push origin workXX_nanolevel #saved back on github
$git branch -u origin/workXX_nanolevel # connected, so in future only need to do a 'git push'.
Branch 'workXX_nanolevel' set up to track remote branch 'workXX_nanolevel' from 'origin'
Do a 'git push' it at every small success so work is backed up.
To visualize the branches, for any repo click on
insights
network (bottom left)
Hover over the visbile commits to better understand.
For this arduino environment, there appears to be 3 basic working modes
personal= ModularSensors\examples\logging_to_EnviroDIY # stuff you easily modify and change, as above.
local= ModularSensors\src # created or collected by the good folks at enviroDIY
submodules= eg TinyGSM # created by other folks as part of open sourcing - see below.
For changes to ModularSensors\src, these are not included directly in the build.
working with ModularSensors src
Submodule for TinyGSM. Submodules are great and a pain. Your point of view and choice. Not needed unless you have to do an update and want to PR back. I try and have a standard source for the repo to be able to compare with about what a branch/PR has on it. Your methods maybe different.
#similarly kellerModbus
$git clone git@github.com:neilh10/KellerModbus.git
$git remote add upstream git@github.com:EnviroDIY/KellerModbus.git
$git remote -v
$cd ~/Documents/Arduino/env03/ModularSensors/examples/logging_to_EnviroDIY/lib
$git clone git@github.com:neilh10/KellerModbus.git
git checkout -b work_XX_nanolevel
changes
$git status
$git add .
$git commit -m "initial setup"
$git push origin work_XX_nanolevel
$git branch -u origin/work_XX_nanolevel