5 June, 2019 / Timeless
Places | Actions | Communications |
---|---|---|
repositories | fork | remote |
fork | push | issues |
upstream | pull | pull request |
local | merge | . |
. | commit | . |
. | fetch | . |
Sort of loose, conceptual categories for these slides...
Origin repo has sequentially tracked versions
One must pull the origin to workstation for local repo clone/copy.
git clone https://github.com/<username>/<repo>.git
Can make changes locally on master branch or topically named branch:
git checkout -b leafy_branch
As a quick aside, always good to run frequently
git status
to get more info Can also check what available branches are present via
git branch
When work is done, prep via add and commit!
git add <modified_file_list_here>
git commit -m '<meaningful short message of changes>'
Push local work to origin
git push
git push origin X
These commands are used more for personal repos, for which you are the creator.
So what if you have friends?
You must fork the repo! Done directly on GitHub
Makes a copy of the repo at its current state in your account
Now treat forked repo as origin, as before
Won't be working on upstream till later.
After the fork, origin is repo in your account
Repo you forked from becomes upstream, pull/push from origin as usual
What about if changes are made since to the upstream you forked from???!!!
Create a remote to the upstream repo
git remote add upstream https://github.com/<someones_username>/<repo>.git
Then sync the local one by fetching the upstream, then merging it and the local master
git fetch upstream
git checkout master
git merge upstream/master
So far, push only changed your forked repo, the origin.
Ask changes to be reflected in upstream via Pull Request
Alerts maintainer to review requested changes. One should:
Collaborative Work | . | Personal Repo Work |
---|---|---|
. |
General
git status
oftengit commit -m "Adds input feature x to script y"
Personal Repos
Collaborative Work
git clone https://github.com/<your_username>/<repo_name>.git
cd repo_name
git checkout -b <new_branch>
git branch
or git status
to get more infogit checkout <other_branch_name>
git checkout master
of coursegit branch
or git status
git clone https://github.com/<your_username>/<repo_name>.git
cd repo_name
git checkout -b <new_feature_branch_name>
git add <modified_file_list_here>
git commit -m '<meaningful short message about the changes made>'
git push origin <new_feature_branch_name>
git clone https://github.com/<your_username>/<repo_name>.git
cd repo_name
git remote add upstream https://github.com/<upstream_username>/<repo_name>.git
git remote -v
git fetch upstream
git checkout master
git merge upstream/master
git checkout -b <new_feature_branch_name>
git add <modified_file_list_here>
git commit -m '<meaningful short message about the changes made>'
git push origin <new_feature_branch_name>
git fetch upstream
step and keep contributing!