Using GitHub and Git on Windows.
First fork on GitHub and then clone
On GitHub do a fork:
My clone is:
git clone https://github.com/samans/yang
Git Merge Update:
- git fetch upstream (fetch all upstream, aka YangModels/yang, branches and put them in upstream/master etc.)
- git checkout master (switch to your local master)
- git merge upstream/master (merge the changes that you fetched in step 1)
Check that my PC workspace is up-to-date with origin/master
- git fetch (this fetches origin and therefore updates origin/master)
- git checkout master (this switches to master; it also warns you if origin/master is ahead of master)
- git pull (this pulls changes from origin/master to master; this should be a fast-forward)
Do the new work in a branch
git checkout -b newThing
**do the modifications necessary**
git add -A (or list the files)
git push -u origin newThing
Then go to github and do a pull request that will request YangModels/yang to be updated with newThing from origin (my remote).
Example of running Git: (FYI)
I have a clone of my fork of the YangModels/yang repository on my PC running Cygwin.
To fork and clone:
Get a GitHub account. Mine is https://github.com/samans (this information will be used in the example below).
Go to the YangModels/yang repository: https://github.com/YangModels/yang
Click the Fork button and pick your repository as the target.
Click on the Clone or download button.
Click on the button that is circled to copy the path to your clipboard.
Go to Cygwin to a folder where you want the clone to be.
Run “git clone <<your repository>>
Syncing with master:
If it has been a while since you cloned, it is very possible that your repository and your local clone on your PC are out of sync with the yang master. If you use the yang repository like I do, I only sync when I want to upload something new. I don’t do development or other work in my clone on my PC. So I want my copy of the repository to be a duplicate of the YangModels/yang master branch.
If this is the first time, you will need to make sure your upstream repository is set correctly.
Do a: “git remote add upstream https://github.com/YangModels/yang”
You can check by running git remote -v
My origin is set to my fork and the upstream is set to the YangModels/yang repository.
I need to sync, I can tell by looking at my repository in github:
Fetch Upstream: The brings down the changes from the YangModels/Yang master branch.
git fetch upstream
Check out the master branch of your local repository
git checkout master
Merge the changes from upstream master to your local master
git merge upstream/master
That command has the potential to produce a lot of output.
Now push changes to your remote repository.
git push origin master
Now check github…
Now ready to do whatever updates you need.
Do a checkout and identify a branch
git checkout -b newThing
If you add files you need to do a git add
Do a git commit
Push to my fork
Then submit the pull request to YangModels/yang on github