https://github.com/<ORG-OR-USER-NAME>/<REPO-NAME>
https://github.com/<YOUR-GH-USERNAME>
https://github.com/<YOUR-GH-USERNAME>/software-training
git config --global user.name "Your Name"
git config --global user.email "your@email.here"
# verify the change above was set
git config --get --global user.email
git config --get --global user.name
In your terminal navigate to your workspace
git clone <PASTE-CLIPBOARD-CONTENTS-HERE>
cd ~/<REPOSITORY-FOLDER>
git remote add rj https://github.com/RoboJackets/software-training.git
git remote set-url origin https://github.com/<YOUR-GH-USERNAME>/software-training.git
git remote -v
rj
origin
Now when you do:
git remote -v
You should see:
origin https://github.com/<YOUR-GH-USERNAME>/software-training.git (fetch)
origin https://github.com/<YOUR-GH-USERNAME>/software-training.git (push)
rj https://github.com/RoboJackets/software-training.git (fetch)
rj https://github.com/RoboJackets/software-training.git (push)
All terminal git commands are in the form:
git <command> <param1> <param2> ...
git clone https://github.com/...
git config <other params>
We can keep our fork up to date with the git pull
command
cd software-training # or wherever your repo is
git pull rj master
git pull
: pull from one GitHub repository into our current repositoryrj
: the name of the repo that we are pulling frommaster
: pull into the "master" branch of our current repositorygit status
is your friendgit status
to see the status of your repogit add file.txt
git add directory
git add .
git add *
git commit -m "Added a file!"
commit
: Commit currently staged changes to git
-m "..."
: Commits require commit messages to label them
git status
can show you if you have any unstaged changes and what you can commit-<letter>
and --<word>
are often times used to set values for specific values-m "..."
sets the message parameter to the value in quotes-m
and --message
can be used interchangeably for git commit
-h
or --help
to show how to use themgit push origin master
git push
: Command to push commits to another repository
origin
: Name of the repo to push to (origin is referring to our fork)master
: Name of the branch to push to (still top secret material)
Good commit messages | Bad commit messages |
![]() |
![]() |
git pull
do?git push
do?git
's solutiongitk
git
integrations for your favorite editor!Create branches with
# git branch <BRANCH_NAME>
# Create two branches, starting from the current commit
git branch stableRj
git branch betaRj
git status
will display info on your current branchgit checkout
lets you switch between branches
Let's checkout the stableRj
branch now
git status
#> On branch master
#> nothing to commit, working tree clean
# git checkout <BRANCH_NAME>
git checkout stableRj
#> Switched to branch 'stableRj'
git status
#> On branch stableRj
#> nothing to commit, working tree clean
Let's add a commit to the stableRj
branch
echo "Stability counts!" > stable_release.txt
git status
git add -A
git status
git commit -m "Add stable_release.txt"
git status
Let's make an experimental commit on the betaRj
branch
git checkout betaRj
echo "This feature is unstable!" > beta_release.txt
git add -A
git commit -m "Add beta_release.txt"
stableRj
branch was behind the betaRj
branch, the commit history has divergedPlay around and checkout the various branches!
git checkout <BRANCH>
ls
betaRj
branch onto the stableRj
branchstableRj
and the betaRj
branch have 'diverged'We need to bring them back together, this is called a merge
# Checkout to the branch we want to merge **into** aka the "base branch"
git checkout stableRj
# Merge the branch we want (betaRj) into the current branch (stableRj)
git merge betaRj
# This will launch an editor, save and quit it to complete
A pull request (PR) is a request for a project owner to merge a branch from your fork into their repository
push PR
laptop -----> fork -----> upstream
^ | |
| v v
|---------------------------
pull
Push code locally stored on your computer to your fork on GitHub
git push origin stableRj
# start on master
git checkout master
# Ensure we branch off from a recent version
git pull rj master
# create a new branch
git branch my-new-feature
git checkout my-new-feature
# Add commits with your work
git commit -m "Fix all of RoboJackets"
# push to a seperate branch on your fork
git push origin my-new-feature
# Go to github, and click 'new pull request'
# add updates by
git commit -m "Add missing files"
git push origin my-new-feature