a system that records changes to a file or set of files over time so that you can recall specific versions later
Think of this as a folder in your filesystem
user@machine:$ mkdir myproject
user@machine:$ cd myproject
user@machine:myproject$ git init
Initialized empty Git repository in myproject/.git/
user@machine:myproject$ ls -a
. .. .git
user@machine:myproject$ echo "Git/Github tutorial from UO Bioinformatics program" > README.md
user@machine:myproject$ git status
# On branch master
#
# Initial commit
#
# Untracked files:
# (use "git add ..." to include in what will be committed)
#
# README.md
nothing added to commit but untracked files present (use "git add" to track)
user@machine:myproject$ git add README.md
user@machine:myproject$ git status
# On branch master
#
# Initial commit
#
# Changes to be committed:
# (use "git rm --cached ..." to unstage)
#
# new file: README.md
#
user@machine:myproject$ git commit
1 Adding readme to project.
2 # Please enter the commit message for your changes. Lines starting
3 # with '#' will be ignored, and an empty message aborts the commit.
4 # On branch master
5 #
6 # Initial commit
7 #
8 # Changes to be committed:
9 # (use "git rm --cached ..." to unstage)
10 #
11 # new file: README.md
12 #
user@machine:myproject$ git log
commit 0000000somecommitnumber00000000000000
Author: Zsailer
Date: Thu Jul 7 10:41:05 2016 -0700
Adding readme to project
List current branches.
user@machine:myproject$ git branch
* master
Create a branch named feature
user@machine:myproject$ git branch feature
user@machine:myproject$ git branch
feature
* master
Switch to that branch.
user@machine:myproject$ git checkout feature
Switched to branch 'feature'
Hint: Repeat the same steps as we did with the master branch.
checkout
your master branch.add
it to your git workspacecommit
it to your project history.Note: the file you added to the feature branch is not in your repository.
Make sure you are on the master branch
user@machine:myproject$ git branch
feature
* master
Merge feature branch into master branch.
user@machine:myproject$ git merge feature
Merge made by recursive.
test.txt | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
create mode 100644 test.txt
Remote host for Git projects.
A home for software collaboration.
Pick a professional username.
Add the remote repository with nickname "origin".
user@machine:myproject$ git remote add origin https://github.com/Zsailer/myproject
Now let's see what happened.
user@machine:myproject$ git remote -v
origin https://github.com/Zsailer/myproject (fetch)
origin https://github.com/Zsailer/myproject (push)
i.e. push your local "master" branch to "origin".
user@machine:myproject$ git push origin master
Counting objects: 11, done.
Delta compression using up to 12 threads.
Compressing objects: 100% (7/7), done.
Writing objects: 100% (11/11), 865 bytes, done.
Total 11 (delta 3), reused 0 (delta 0)
To git@github.com:Zsailer/myproject.git
* [new branch] master -> master
You now have a project on Github!
Finally, we're ready to learn how to
start a new line of development from a remote repo (like branching).
merge a forked repo into another remote repo (like merging.)
Go to github.com/Zsailer/hello-from-uo-bioinfo
and click fork.
user@machine:$ git clone https://github.com/username/hello-from-uo-bioinfo
Cloning into 'hello-from-uo-bioinfo'...
remote: Counting objects: 19, done.
remote: Compressing objects: 100% (16/16), done.
remote: Total 19 (delta 6), reused 9 (delta 1), pack-reused 0
Unpacking objects: 100% (19/19), done.
Checking connectivity... done.
Add a link to the remote repo as well (named it "upstream")
user@machine:$ git remote add upstream https://github.com/Zsailer/hello-from-uo-bioinfo
user@machine:$ git push origin addme
Counting objects: 2, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 228 bytes | 0 bytes/s, done.
Total 2 (delta 1), reused 0 (delta 0)
Go to your fork on Github and click pull request.
add a description and create pull request
Pull from upstream
user@machine:$ git pull upstream master
and push the updates to all branches.
user@machine:$ git push --all origin
Merge conflicts!