NTRO on use of GITHUB.COM and Git
After setting up git
and registering for a public account (free) on github.com and setting up and becoming familiar with github.
Then Create A Repository https://help.github.com/articles/create-a-repo
Fork a Repository
To make my own Fork (a snapshot in time of a copy of another repository on github)
see "Fork a Repository" https://help.github.com/articles/fork-a-repo
Using the above, I forked: github.com/seandepagnier
/weatherfax_pi to github.com/rgleason/weatherfax_pi about six months ago.
Clone the Fork to your Local Repository
Next "Clone your Fork to a Local Repository" read the end of Fork-a-repo
Note how to keep track of the original repository (seandepagnier/weatherfax_pi) by "Configuring Remotes" by adding 'upstream'.
Six months went by and Sean Depagnier had made changes to his repository.
I needed to get my fork up to date with Sean's repository.
Synch a Fork
So I "Synched a Fork" https://help.github.com/articles/syncing-a-fork
Syncing your fork only updates your local copy of the repository; it does not update your repository on GitHub.
Done using the commands:
git remote -v
git remote add upstream https://github.com/seandepagnier/weatherfax_pi.git
git remote -v
git fetch upstream
git branch -va -Should show the most current upstream commit.
"remotes/upstream/master 5fdff0f Some upstream commit"
Now your Local repository on your computer has a remote branch 'upstream' with the most current
commits from seandepagnier/weatherfax_pi
We have fetched the 'upstream' repository.
Next we need to Merge those changes into our local repository.
git checkout master (now pointing to the local repository master)Make changes on the Local, compile, test and then Commit.
git merge upstream/master (now merging upstream to the local master)
After getting the local repository current with the original repository seandepagnier/weatherfax_pi,
we've made some changes and run some tests on the changes by compiling the code with MSVC++
and those changes work fine. Now we need to commit the changes and updat the personal repository on gitub:
Commit those changes and add an identifying note.
Then publish the commits from your repository into a remote for other users to view and potentially fetch.
Commit changes made.
1. Determine any untracked files that are needed as a part of the commit using git status. Write them down.
2. Add necessary untracked files using git add <file1> <file2> etc.
3. Check for untracked files again using git status.
3. Then commit using git commit -a
show files added to the staging area, files with changes, and untracked files
git diff show a diff of the changes made since your last commit to diff one file: "git diff -- <filename>" to show a diff between staging area and HEAD: `git diff --cached`
git add <file1> <file2> ... add <file1>, <file2>, etc... to the project git add <dir> add all files under directory <dir> to the project, including subdirectories
git commit -aUpdate your personal forked repository on GitHub
commit all files changed since your last commit
(does not include new (untracked) files)
. ( github.com/rgleason/weatherfax_pi )
When you've made your awesome updates locally, you'll want to synchronize that work back onto GitHub. It's super easy to do:
You can only push to one of two writeable protocol URL addresses.
Those two include an SSH URL like email@example.com:user/repo.git
or HTTPS URL like https://github.com/user/repo.git.
If you cloned a repository with a read-only git:// URL and you have been granted permissions to write to it, you can update the URL to one of the writable forms with:
git remote set-url origin <NEWURL>
Pushing a Branch
To push a local branch to an established remote, you need to issue the command:
git push <REMOTENAME> <BRANCHNAME>
This is most typically invoked as
git push origin master
update the server with your commits across all branches that are *COMMON*
between your local copy and the server. Local branches that were never
pushed to the server in the first place are not shared.
git push origin <branch>
update the server with your commits made to <branch> since your last push.
This is always *required* for new branches that you wish to share. After
the first explicit push, "git push" by itself is sufficient.
After the [git push origin master] is issued, open github and check the commits in your forked repository.
For example: https://github.com/rgleason/weatherfax_pi
To issued the "pull request" to sean was quite easy. I had two commits in the bin waiting.
I picked the "Compare" button on the right which created a diff and showed the pull details and had a green button to make the pull request.
Git Help https://help.github.com
Git Cheatsheet https://help.github.com/articles/git-cheatsheet
Cheatsheet $ command line ruby cheat sheets