Git and Git Cola Tutorial

GIT TUTORIAL
ref: http://rogerdudler.github.io/git-guide/
1. Create a new repository
create a new directory, open it and perform a
git init
to create a new git repository.

2. checkout a repository
create a working copy of a local repository by running the command
git clone /path/to/repository
git clone https://github.com/balanced/balanced-php.git
when using a remote server, your command will be
git clone username@host:/path/to/repository
git clone advcha@yahoo.com:https://github.com/balanced/balanced-php.git

3. workflow
your local repository consists of three “trees” maintained by git. the first one is your “Working Directory” which holds the actual files. the second one is the “Index” which acts as a staging area and finally the “HEAD” which points to the last commit you’ve made.

4. add & commit
You can propose changes (add it to the Index) using
git add <filename>
git add *
This is the first step in the basic git workflow. To actually commit these changes use
git commit -m “Commit message”
Now the file is committed to the HEAD, but not in your remote repository yet.

5. pushing changes
Your changes are now in the “HEAD” of your local working copy. To send those changes to your remote repository, execute
git push origin master
Change master to whatever branch you want to push your changes to.

If you have not cloned an existing repository and want to connect your repository to a remote server, you need to add it with
git remote add origin <server>
Now you are able to push your changes to the selected remote server

6. branching
Branches are used to develop features isolated from each other. The master branch is the “default” branch when you create a repository. Use other branches for development and merge them back to the master branch upon completion.

create a new branch named “feature_x” and switch to it using
git checkout -b feature_x
switch back to master
git checkout master
and delete the branch again
git branch -d feature_x
a branch is not available to others unless you push the branch to your remote repository
git push origin <branch>

7. update & merge
to update your local repository to the newest commit, execute
git pull
in your working directory to fetch and merge remote changes.
to merge another branch into your active branch (e.g. master), use
git merge <branch>
in both cases git tries to auto-merge changes. Unfortunately, this is not always possible and results in conflicts. You are responsible to merge those conflicts manually by editing the files shown by git. After changing, you need to mark them as merged with
git add <filename>
before merging changes, you can also preview them by using
git diff <source_branch> <target_branch>

8. tagging
it’s recommended to create tags for software releases. this is a known concept, which also exists in SVN. You can create a new tag named 1.0.0 by executing
git tag 1.0.0 1b2e1d63ff
the 1b2e1d63ff stands for the first 10 characters of the commit id you want to reference with your tag. You can get the commit id by looking at the log

9. log
in its simplest form, you can study repository history using..
git log
You can add a lot of parameters to make the log look like what you want. To see only the commits of a certain author:
git log –author=bob
To see a very compressed log where each commit is one line:
git log –pretty=oneline
Or maybe you want to see an ASCII art tree of all the branches, decorated with the names of tags and branches:
git log –graph –oneline –decorate –all
See only which files have changed:
git log –name-status
These are just a few of the possible parameters you can use. For more, see
git log –help

10. replace local changes
In case you did something wrong, which for sure never happens ;), you can replace local changes using the command
git checkout — <filename>
this replaces the changes in your working tree with the last content in HEAD. Changes already added to the index, as well as new files, will be kept.

If you instead want to drop all your local changes and commits, fetch the latest history from the server and point your local master branch at it like this
git fetch origin
git reset –hard origin/master

11. useful hints
built-in git GUI
gitk
use colorful git output
git config color.ui true
show log on just one line per commit
git config format.pretty oneline
use interactive adding
git add -i

GIT COLA
tutorial: http://cerebrux.net/2013/02/07/github-git-cola-gui-step-by-step-management-of-your-code/
1) Install Git Cola GUI through Software Center or through terminal:
sudo apt-get install git-cola
2) Copy the repository link from the website then Launch Git Cola and paste the link. In terminal, it’s equivalent of
git clone /github/repo/link.git
Once you launch the Git Cola click «Clone» and paste the link you have copied from Github
Once you provided the link, select where to download the repository and click «Open»
This is the main window. It’s empty because we haven’t changed any code
3) You can edit your preferences by clicking Edit menu were you can customize your settings like email, username, prepared editor etc. In terminal it’s equivalent of:
git config –global user.name ‘John Doe’
git config –global user.email ‘johndoe@mail.com’
To edit your preferences, click on «Edit –> Preferences»
4) Now edit some files inside your local repository clone and the hit the refresh Rescan button on Git Cola. In terminal, it’s equivalent of:
git status
and
git diff
Open the file that you need to edit and start editing. Save and close the file
5) Now once you can hit Stage, Comment to add a message for the changes and the Commit these changes:
In terminal, it’s equivalent of
git add filename
git add README.md
and then
git commit -m ‘Commit message’
git commit -m ‘Update the README file for better description’
OR COMBINE ADD AND COMMIT LIKE THIS:
git commit -a -m ‘Update the README file for better description’
Click Stage, add some comment and then commit
6) You can also Tag your changes to create versions of your repo by clicking Actions menu –> Create Tag
In terminal, it’s equivalent of
git tag -a v4.5.6 -m ‘my version 4.5.6’
Create tag by clicking «Actions –> Add Tag»
7) Now you can upload (push) your changes and versions (tags) to your GitHub account.
In terminal, it’s equivalent of
git push origin master
and your tag with
git push origin v1.0.4
Click on «Push» on the main window, check that «Include tags» is activated and then click Push
Provide your Username and Password of your Github account
Check the commands tab to see the background messages
8) Now you can go to your Github page to see your changes and your tags
Refresh the GitHub page to see your comment and the commit history

I WANT TO UPDATE MY LOCAL REPOSITORY:
ref:http://stackoverflow.com/questions/1443210/updating-a-local-repository-with-changes-from-a-github-repository
teddy@teddy-K43SJ:~/Documents/java/processing-java-client$ git pull origin master
Username for ‘https://github.com’: advcha
Password for ‘https://advcha@github.com’:
From https://github.com/finix-payments/processing-java-client
* branch            master     -> FETCH_HEAD
Updating 79ff8fe..c52614a
error: Your local changes to the following files would be overwritten by merge:
src/main/java/com/finix/payments/processing/client/Configuration.java
src/main/java/com/finix/payments/processing/client/model/User.java
Please, commit your changes or stash them before you can merge.
Aborting
ref:http://stackoverflow.com/questions/15745045/how-do-i-resolve-git-saying-commit-your-changes-or-stash-them-before-you-can-me
https://git-scm.com/book/en/v1/Git-Tools-Stashing
so pls do:
git stash
then repeat:
git pull origin master

I ADDED A .gitignore FILE. I ALREADY ADD AND COMMIT THE FILE BUT THEN I GOT ERROR HERE WHEN TRYING TO PUSH A CHANGES:
! [rejected]        master -> master (fetch first)
error: failed to push some refs to ‘https://github.com/advcha/persuratan.git’
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., ‘git pull …’) before pushing again.
hint: See the ‘Note about fast-forwards’ in ‘git push –help’ for details.
SO ACTUALLY I DELETED A FEW FILES (WITH ~) ON THE REMOTE REPO. I NEED TO UPDATE MY LOCAL REPO FIRST
git pull origin master
THEN PUSH AGAIN
git push origin master

IF WE DONT WANT TO UPLOAD/PUSH A FILE LIKE database.php
1. Create a new file .gitignore
here is the content:
app/config/database.php
2. type: git commit -a -m ‘add .gitignore file’
3. type: git push OR git push origin master

REMOTE, BRANCH, CHECKOUT
1. check our remote repo:
type: git remote OR MORE DETAIL git remote -v
teddy@teddy-K43SJ:~/Documents/works/persuratan$ git remote -v
origin    https://github.com/advcha/persuratan.git (fetch)
origin    https://github.com/advcha/persuratan.git (push)

2. We can add a branch in the remote repo.
on the remote repo website, just click the down arrow at Branch:master then type a branch we want like: addfeature

3. in local repo, check our branch
git branch
teddy@teddy-K43SJ:~/Documents/works/persuratan$ git branch
* master
WE ONLY HAVE ONE BRANCH ‘master’ YET
4. create a local repo:
git branch addfeature
teddy@teddy-K43SJ:~/Documents/works/persuratan$ git branch addfeature
THEN check again:
teddy@teddy-K43SJ:~/Documents/works/persuratan$ git branch
addfeature
* master
5. to switch to the new local repo:
git checkout addfeature
teddy@teddy-K43SJ:~/Documents/works/persuratan$ git checkout addfeature
Switched to branch ‘addfeature’
6. make a change in index.html file (AYNTHING) then check status:
teddy@teddy-K43SJ:~/Documents/works/persuratan$ git status
On branch addfeature
Changes not staged for commit:
(use “git add <file>…” to update what will be committed)
(use “git checkout — <file>…” to discard changes in working directory)

modified:   index.html

no changes added to commit (use “git add” and/or “git commit -a”)
teddy@teddy-K43SJ:~/Documents/works/persuratan$ git commit -a -m ‘change index.php test’
[addfeature fc28a68] change index.php test
1 file changed, 103 insertions(+), 102 deletions(-)
rewrite index.html (97%)
7. commit the changes
teddy@teddy-K43SJ:~/Documents/works/persuratan$ git commit -a -m ‘change index.php test’
[addfeature fc28a68] change index.php test
1 file changed, 103 insertions(+), 102 deletions(-)
rewrite index.html (97%)
8. then push to the remote repo (branch ‘addfeature’)
teddy@teddy-K43SJ:~/Documents/works/persuratan$ git push addfeature
9. Check the remote repo
index.html in master branch not affected ONLY in addfeature branch
10. merge the branch to master(NOT WORKING!!!)
git merge master
git checkout master
git push
OK THIS HAS TO BE DONE IN github PAGE. FIRST CLICK ‘New Pull Request’
11. Click ‘Create Pull Request’ … THEN WE CAN MERGE IT
AT LAST WE CAN DELETE THE ‘addfeature’ BRANCH BECAUSE ITS ALREADY MERGED TO ‘master’ BRANCH!
WE CAN ALSO DELETE THE REMOTE BRANCH FROM TERMINAL WITH git push origin :addfeature (BE CAREFULL!!!)
teddy@teddy-K43SJ:~/Documents/works/persuratan$ git push origin :addfeature
Username for ‘https://github.com’: advcha
Password for ‘https://advcha@github.com’:
error: unable to delete ‘addfeature’: remote ref does not exist
error: failed to push some refs to ‘https://github.com/advcha/persuratan.git’
ref:http://makandracards.com/makandra/621-git-delete-a-branch-local-or-remote
http://stackoverflow.com/questions/2003505/delete-a-git-branch-both-locally-and-remotely
12. NOW WE NEED TO MERGE IT ALSO IN OUR LOCAL REPO
type: git checkout master
then: git pull
teddy@teddy-K43SJ:~/Documents/works/persuratan$ git checkout master
Already on ‘master’
Your branch is up-to-date with ‘origin/master’.
teddy@teddy-K43SJ:~/Documents/works/persuratan$ git pull
remote: Counting objects: 1, done.
remote: Total 1 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (1/1), done.
From https://github.com/advcha/persuratan
1d338b5..7cc859e  master     -> origin/master
Updating 1d338b5..7cc859e
Fast-forward
index.html | 187 +++++++++++++++++++++++++++++++——————————
1 file changed, 94 insertions(+), 93 deletions(-)
13. DELETE LOCAL BRANCH ‘addfeature’ (ref:http://makandracards.com/makandra/621-git-delete-a-branch-local-or-remote)
type: git branch -d addfeature
teddy@teddy-K43SJ:~/Documents/works/persuratan$ git branch -d addfeature
Deleted branch addfeature (was fc28a68).
14. Check the branch again
teddy@teddy-K43SJ:~/Documents/works/persuratan$ git branch
* master
15. SYNCHRONIZED THE BRANCHES (REMOTE & LOCAL)
teddy@teddy-K43SJ:~/Documents/works/persuratan$ git fetch -p
From https://github.com/advcha/persuratan
x [deleted]         (none)     -> origin/addfeature

MERGE TWO REPOSITORIES
re:http://saintgimp.org/2013/01/22/merging-two-git-repositories-into-one-repository-without-losing-file-history/
http://stackoverflow.com/questions/1425892/how-do-you-merge-two-git-repositories

REAL WORLD SAMPLE DEVELOPMENT WITH GITHUB:http://nvie.com/posts/a-successful-git-branching-model/

WORKING SAMPLE FROM SCRATCH
1. Create a new repository in my github account: OpenCV-python (https://github.com/advcha/OpenCV-Python.git)
2. in my terminal, clone it into /media/data/MASTER/opencv/
teddy@teddy-K43SJ:/media/data/MASTER/opencv$ git clone https://github.com/advcha/OpenCV-Python.git
Cloning into ‘OpenCV-Python’…
remote: Counting objects: 3, done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), done.
Checking connectivity… done.
3. Add some files and directories in it like images/ and opencv_read_write.py (I copied them from /home/teddy/opencv/samples/python/) OR SEARCH THE FILENAME IN /media/data/MASTER/opencv/opencv_python_tutorial.txt
4. check the un-uploaded file and dir with ‘git status’:
teddy@teddy-K43SJ:/media/data/MASTER/opencv/OpenCV-Python$ git status
On branch master
Your branch is up-to-date with ‘origin/master’.

Untracked files:
(use “git add <file>…” to include in what will be committed)

images/
opencv_read_write.py

nothing added to commit but untracked files present (use “git add” to track)
5. Add the file and the dir to prepare for uploading with ‘git add *’:
teddy@teddy-K43SJ:/media/data/MASTER/opencv/OpenCV-Python$ git add *

6. Commit the file and dir and give it a tag ‘upload some python scripts’:
teddy@teddy-K43SJ:/media/data/MASTER/opencv/OpenCV-Python$ git commit -a -m ‘upload some python scripts’
[master 46abb81] upload some python scripts
28 files changed, 17 insertions(+)
create mode 100644 images/Temperate 09 – Small.png
create mode 100644 images/Temperate 09 – Small_clean.png
create mode 100644 images/approx.jpg
create mode 100644 images/bolt.png
create mode 100644 images/clahe.jpg
create mode 100644 images/dave.jpg
create mode 100644 images/dave.png
create mode 100644 images/fruits.jpg
create mode 100644 images/fruits_gray.jpg
create mode 100644 images/grass.png
create mode 100644 images/hand.jpg
create mode 100644 images/john_dory-zeus_faber.jpg
create mode 100644 images/mario.jpg
create mode 100644 images/mario_coin.png
create mode 100644 images/mario_coin1.png
create mode 100644 images/messi5.jpg
create mode 100644 images/messi_face.jpg
create mode 100644 images/more_coins.png
create mode 100644 images/my_family.jpg
create mode 100644 images/noisy2.png
create mode 100644 images/opencv_logo.png
create mode 100644 images/rect.jpg
create mode 100644 images/shapes.png
create mode 100644 images/star.jpg
create mode 100644 images/star2.jpg
create mode 100644 images/uss_arizona.jpg
create mode 100644 images/water_coins.jpg
create mode 100644 opencv_read_write.py

7. Push them to github account with ‘git push origin master’:
teddy@teddy-K43SJ:/media/data/MASTER/opencv/OpenCV-Python$ git push origin master
Username for ‘https://github.com’: advcha
Password for ‘https://advcha@github.com’:
Counting objects: 32, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (31/31), done.
Writing objects: 100% (31/31), 5.93 MiB | 1.10 MiB/s, done.
Total 31 (delta 0), reused 0 (delta 0)
To https://github.com/advcha/OpenCV-Python.git
330ef49..46abb81  master -> master

8. Check again my local repo with ‘git status’:
teddy@teddy-K43SJ:/media/data/MASTER/opencv/OpenCV-Python$ git status
On branch master
Your branch is up-to-date with ‘origin/master’.

nothing to commit, working directory clean

OK DONE

9. Add some python scripts from /home/teddy/opencv/samples/python/ (copy and paste them into /media/data/MASTER/opencv/OpenCV-Python)

10. check with ‘git status’:
teddy@teddy-K43SJ:/media/data/MASTER/opencv/OpenCV-Python$ git status
On branch master
Your branch is up-to-date with ‘origin/master’.

Untracked files:
(use “git add <file>…” to include in what will be committed)

drawing.py
mouse_draw.py
mouse_paint.py
mouse_paint_img.py

nothing added to commit but untracked files present (use “git add” to track)

11. add them with ‘git add *’:
teddy@teddy-K43SJ:/media/data/MASTER/opencv/OpenCV-Python$ git add *

12. commit them:
teddy@teddy-K43SJ:/media/data/MASTER/opencv/OpenCV-Python$ git commit -a -m ‘Upload some python scripts’
[master 567e4fd] Upload some python scripts
4 files changed, 165 insertions(+)
create mode 100644 drawing.py
create mode 100644 mouse_draw.py
create mode 100644 mouse_paint.py
create mode 100644 mouse_paint_img.py

13. The last, push them into my github account:
teddy@teddy-K43SJ:/media/data/MASTER/opencv/OpenCV-Python$ git push origin master
Username for ‘https://github.com’: advcha
Password for ‘https://advcha@github.com’:
Counting objects: 7, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (6/6), done.
Writing objects: 100% (6/6), 2.66 KiB | 0 bytes/s, done.
Total 6 (delta 0), reused 0 (delta 0)
To https://github.com/advcha/OpenCV-Python.git
46abb81..567e4fd  master -> master

OK. DO IT OVER AND OVER AGAIN FOR THE OTHERS FILES AND DIRECTORIES!!!

HOW TO UPDATE FILE AND UPDATE THE CHANGES TO REMOTE REPO?
1. Modify README.md to
Some python scripts for practising OpenCV. Use Python 2.7 (some scripts works for Python 3.4) and OpenCV 3.1.0.
SAVE THE MODIFICATION   (IT BETTER TO REMOVE THE TEMPORARY FILE LIKE README.md~)
2. check the status:
teddy@teddy-K43SJ:/media/data/MASTER/opencv/OpenCV-Python$ git status
On branch master
Your branch is up-to-date with ‘origin/master’.

Changes not staged for commit:
(use “git add <file>…” to update what will be committed)
(use “git checkout — <file>…” to discard changes in working directory)

modified:   README.md

Untracked files:
(use “git add <file>…” to include in what will be committed)

README.md~

no changes added to commit (use “git add” and/or “git commit -a”)
3. use ‘git add *’
teddy@teddy-K43SJ:/media/data/MASTER/opencv/OpenCV-Python$ git add *
4. commit:
teddy@teddy-K43SJ:/media/data/MASTER/opencv/OpenCV-Python$ git commit -a -m ‘Update README’
[master c7ea471] Update README
2 files changed, 3 insertions(+), 1 deletion(-)
create mode 100644 README.md~
5. use ‘git push’:
teddy@teddy-K43SJ:/media/data/MASTER/opencv/OpenCV-Python$ git push origin master
Username for ‘https://github.com’: advcha
Password for ‘https://advcha@github.com’:
Counting objects: 5, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 367 bytes | 0 bytes/s, done.
Total 3 (delta 1), reused 0 (delta 0)
To https://github.com/advcha/OpenCV-Python.git
1f66fba..c7ea471  master -> master

LOCAL REPO DIRECTORY HAS DIFFERENT NAME WITH REMOTE REPO:
ref:http://stackoverflow.com/questions/8570636/change-name-of-folder-when-cloning-from-github
git clone https://github.com/sferik/sign-in-with-twitter.git signin
REMOTE REPO: sign-in-with-twitter
LOCAL REPO: signin

GITHUB GLOSSARY AND TERMINOLOGY

Source: https://help.github.com/articles/github-glossary/
Below are a list of some Git and GitHub specific terms we use across our sites and documentation.

If you see some Git-related terminology not listed here, you might find an explanation of it in Git Reference or our Git SCM book.

BLAME
The “blame” feature in Git describes the last modification to each line of a file, which generally displays the revision, author and time. This is helpful, for example, in tracking down when a feature was added, or which commit led to a particular bug.

BRANCH
A branch is a parallel version of a repository. It is contained within the repository, but does not affect the primary or master branch allowing you to work freely without disrupting the “live” version. When you’ve made the changes you want to make, you can merge your branch back into the master branch to publish your changes.

CLONE
A clone is a copy of a repository that lives on your computer instead of on a website’s server somewhere, or the act of making that copy. With your clone you can edit the files in your preferred editor and use Git to keep track of your changes without having to be online. It is, however, connected to the remote version so that changes can be synced between the two. You can push your local changes to the remote to keep them synced when you’re online.

COLLABORATOR
A collaborator is a person with read and write access to a repository who has been invited to contribute by the repository owner.

COMMIT
A commit, or “revision”, is an individual change to a file (or set of files). It’s like when you save a file, except with Git, every time you save it creates a unique ID (a.k.a. the “SHA” or “hash”) that allows you to keep record of what changes were made when and by who. Commits usually contain a commit message which is a brief description of what changes were made.

CONTRIBUTOR
A contributor is someone who has contributed to a project by having a pull request merged but does not have collaborator access.

DIFF
A diff is the difference in changes between two commits, or saved changes. The diff will visually describe what was added or removed from a file since its last commit.

FETCH
Fetching refers to getting the latest changes from an online repository (like GitHub.com) without merging them in. Once these changes are fetched you can compare them to your local branches (the code residing on your local machine).

FORK
A fork is a personal copy of another user’s repository that lives on your account. Forks allow you to freely make changes to a project without affecting the original. Forks remain attached to the original, allowing you to submit a pull request to the original’s author to update with your changes. You can also keep your fork up to date by pulling in updates from the original.

GIT
Git is an open source program for tracking changes in text files. It was written by the author of the Linux operating system, and is the core technology that GitHub, the social and user interface, is built on top of.

ISSUE
Issues are suggested improvements, tasks or questions related to the repository. Issues can be created by anyone (for public repositories), and are moderated by repository collaborators. Each issue contains its own discussion forum, can be labeled and assigned to a user.

MARKDOWN
Markdown is an incredibly simple semantic file format, not too dissimilar from .doc, .rtf and .txt. Markdown makes it easy for even those without a web-publishing background to write prose (including with links, lists, bullets, etc.) and have it displayed like a website. GitHub supports Markdown, and you can learn about the semantics here.

MERGE
Merging takes the changes from one branch (in the same repository or from a fork), and applies them into another. This often happens as a Pull Request (which can be thought of as a request to merge), or via the command line. A merge can be done automatically via a Pull Request via the GitHub.com web interface if there are no conflicting changes, or can always be done via the command line. See Merging a pull request.

OPEN SOURCE
Open source software is software that can be freely used, modified, and shared (in both modified and unmodified form) by anyone. Today the concept of “open source” is often extended beyond software, to represent a philosophy of collaboration in which working materials are made available online for anyone to fork, modify, discuss, and contribute to.

ORGANIZATIONS
Organizations are a group of two or more users that typically mirror real-world organizations. They are administered by users and can contain both repositories and teams.

PRIVATE REPOSITORY
Private repositories are repositories that can only be viewed or contributed to by their creator and collaborators the creator specified.

PULL
Pull refers to when you are fetching in changes and merging them. For instance, if someone has edited the remote file you’re both working on, you’ll want to pull in those changes to your local copy so that it’s up to date.

PULL REQUEST (PR)
Pull requests are proposed changes to a repository submitted by a user and accepted or rejected by a repository’s collaborators. Like issues, pull requests each have their own discussion forum. See Using Pull Requests.

PUSH
Pushing refers to sending your committed changes to a remote repository such as GitHub.com. For instance, if you change something locally, you’d want to then push those changes so that others may access them.

REMOTE
This is the version of something that is hosted on a server, most likely GitHub.com. It can be connected to local clones so that changes can be synced.

REPOSITORY
A repository is the most basic element of GitHub. They’re easiest to imagine as a project’s folder. A repository contains all of the project files (including documentation), and stores each file’s revision history. Repositories can have multiple collaborators and can be either public or private.

SSH KEY
SSH keys are a way to identify yourself to an online server, using an encrypted message. It’s as if your computer has its own unique password to another service. GitHub uses SSH keys to securely transfer information from GitHub.com to your computer.

UPSTREAM
When talking about a branch or a fork, the primary branch on the original repository is often referred to as the “upstream”, since that is the main place that other changes will come in from. The branch/fork you are working on is then called the “downstream”.

USER
Users are personal GitHub accounts. Each user has a personal profile, and can own multiple repositories, public or private. They can create or be invited to join organizations or collaborate on another user’s repository.

ref:https://www.kernel.org/pub/software/scm/git/docs/gitglossary.html
alternate object database
Via the alternates mechanism, a repository can inherit part of its object database from another object database, which is called an “alternate”.

bare repository
A bare repository is normally an appropriately named directory with a .git suffix that does not have a locally checked-out copy of any of the files under revision control. That is, all of the Git administrative and control files that would normally be present in the hidden .git sub-directory are directly present in the repository.git directory instead, and no other files are present and checked out. Usually publishers of public repositories make bare repositories available.

blob object
Untyped object, e.g. the contents of a file.

branch
A “branch” is an active line of development. The most recent commit on a branch is referred to as the tip of that branch. The tip of the branch is referenced by a branch head, which moves forward as additional development is done on the branch. A single Git repository can track an arbitrary number of branches, but your working tree is associated with just one of them (the “current” or “checked out” branch), and HEAD points to that branch.

cache
Obsolete for: index.

chain
A list of objects, where each object in the list contains a reference to its successor (for example, the successor of a commit could be one of its parents).

changeset
BitKeeper/cvsps speak for “commit”. Since Git does not store changes, but states, it really does not make sense to use the term “changesets” with Git.

checkout
The action of updating all or part of the working tree with a tree object or blob from the object database, and updating the index and HEAD if the whole working tree has been pointed at a new branch.

cherry-picking
In SCM jargon, “cherry pick” means to choose a subset of changes out of a series of changes (typically commits) and record them as a new series of changes on top of a different codebase. In Git, this is performed by the “git cherry-pick” command to extract the change introduced by an existing commit and to record it based on the tip of the current branch as a new commit.

clean
A working tree is clean, if it corresponds to the revision referenced by the current head. Also see “dirty”.

commit
As a noun: A single point in the Git history; the entire history of a project is represented as a set of interrelated commits. The word “commit” is often used by Git in the same places other revision control systems use the words “revision” or “version”. Also used as a short hand for commit object.

As a verb: The action of storing a new snapshot of the project’s state in the Git history, by creating a new commit representing the current state of the index and advancing HEAD to point at the new commit.

commit object
An object which contains the information about a particular revision, such as parents, committer, author, date and the tree object which corresponds to the top directory of the stored revision.

commit-ish (also committish)
A commit object or an object that can be recursively dereferenced to a commit object. The following are all commit-ishes: a commit object, a tag object that points to a commit object, a tag object that points to a tag object that points to a commit object, etc.

core Git
Fundamental data structures and utilities of Git. Exposes only limited source code management tools.

DAG
Directed acyclic graph. The commit objects form a directed acyclic graph, because they have parents (directed), and the graph of commit objects is acyclic (there is no chain which begins and ends with the same object).

dangling object
An unreachable object which is not reachable even from other unreachable objects; a dangling object has no references to it from any reference or object in the repository.

detached HEAD
Normally the HEAD stores the name of a branch, and commands that operate on the history HEAD represents operate on the history leading to the tip of the branch the HEAD points at. However, Git also allows you to check out an arbitrary commit that isn’t necessarily the tip of any particular branch. The HEAD in such a state is called “detached”.

Note that commands that operate on the history of the current branch (e.g. git commit to build a new history on top of it) still work while the HEAD is detached. They update the HEAD to point at the tip of the updated history without affecting any branch. Commands that update or inquire information about the current branch (e.g. git branch –set-upstream-to that sets what remote-tracking branch the current branch integrates with) obviously do not work, as there is no (real) current branch to ask about in this state.

directory
The list you get with “ls” 🙂

dirty
A working tree is said to be “dirty” if it contains modifications which have not been committed to the current branch.

evil merge
An evil merge is a merge that introduces changes that do not appear in any parent.

fast-forward
A fast-forward is a special type of merge where you have a revision and you are “merging” another branch’s changes that happen to be a descendant of what you have. In such these cases, you do not make a new merge commit but instead just update to his revision. This will happen frequently on a remote-tracking branch of a remote repository.

fetch
Fetching a branch means to get the branch’s head ref from a remote repository, to find out which objects are missing from the local object database, and to get them, too. See also git-fetch(1).

file system
Linus Torvalds originally designed Git to be a user space file system, i.e. the infrastructure to hold files and directories. That ensured the efficiency and speed of Git.

Git archive
Synonym for repository (for arch people).

gitfile
A plain file .git at the root of a working tree that points at the directory that is the real repository.

grafts
Grafts enables two otherwise different lines of development to be joined together by recording fake ancestry information for commits. This way you can make Git pretend the set of parents a commit has is different from what was recorded when the commit was created. Configured via the .git/info/grafts file.

Note that the grafts mechanism is outdated and can lead to problems transferring objects between repositories; see git-replace(1) for a more flexible and robust system to do the same thing.

hash
In Git’s context, synonym for object name.

head
A named reference to the commit at the tip of a branch. Heads are stored in a file in $GIT_DIR/refs/heads/ directory, except when using packed refs. (See git-pack-refs(1).)

HEAD
The current branch. In more detail: Your working tree is normally derived from the state of the tree referred to by HEAD. HEAD is a reference to one of the heads in your repository, except when using a detached HEAD, in which case it directly references an arbitrary commit.

head ref
A synonym for head.

hook
During the normal execution of several Git commands, call-outs are made to optional scripts that allow a developer to add functionality or checking. Typically, the hooks allow for a command to be pre-verified and potentially aborted, and allow for a post-notification after the operation is done. The hook scripts are found in the $GIT_DIR/hooks/ directory, and are enabled by simply removing the .sample suffix from the filename. In earlier versions of Git you had to make them executable.

index
A collection of files with stat information, whose contents are stored as objects. The index is a stored version of your working tree. Truth be told, it can also contain a second, and even a third version of a working tree, which are used when merging.

index entry
The information regarding a particular file, stored in the index. An index entry can be unmerged, if a merge was started, but not yet finished (i.e. if the index contains multiple versions of that file).

master
The default development branch. Whenever you create a Git repository, a branch named “master” is created, and becomes the active branch. In most cases, this contains the local development, though that is purely by convention and is not required.

merge
As a verb: To bring the contents of another branch (possibly from an external repository) into the current branch. In the case where the merged-in branch is from a different repository, this is done by first fetching the remote branch and then merging the result into the current branch. This combination of fetch and merge operations is called a pull. Merging is performed by an automatic process that identifies changes made since the branches diverged, and then applies all those changes together. In cases where changes conflict, manual intervention may be required to complete the merge.

As a noun: unless it is a fast-forward, a successful merge results in the creation of a new commit representing the result of the merge, and having as parents the tips of the merged branches. This commit is referred to as a “merge commit”, or sometimes just a “merge”.

object
The unit of storage in Git. It is uniquely identified by the SHA-1 of its contents. Consequently, an object can not be changed.

object database
Stores a set of “objects”, and an individual object is identified by its object name. The objects usually live in $GIT_DIR/objects/.

object identifier
Synonym for object name.

object name
The unique identifier of an object. The object name is usually represented by a 40 character hexadecimal string. Also colloquially called SHA-1.

object type
One of the identifiers “commit”, “tree”, “tag” or “blob” describing the type of an object.

octopus
To merge more than two branches.

origin
The default upstream repository. Most projects have at least one upstream project which they track. By default origin is used for that purpose. New upstream updates will be fetched into remote-tracking branches named origin/name-of-upstream-branch, which you can see using git branch -r.

pack
A set of objects which have been compressed into one file (to save space or to transmit them efficiently).

pack index
The list of identifiers, and other information, of the objects in a pack, to assist in efficiently accessing the contents of a pack.

pathspec
Pattern used to limit paths in Git commands.

Pathspecs are used on the command line of “git ls-files”, “git ls-tree”, “git add”, “git grep”, “git diff”, “git checkout”, and many other commands to limit the scope of operations to some subset of the tree or worktree. See the documentation of each command for whether paths are relative to the current directory or toplevel. The pathspec syntax is as follows:

any path matches itself

the pathspec up to the last slash represents a directory prefix. The scope of that pathspec is limited to that subtree.

the rest of the pathspec is a pattern for the remainder of the pathname. Paths relative to the directory prefix will be matched against that pattern using fnmatch(3); in particular, * and ? can match directory separators.

For example, Documentation/*.jpg will match all .jpg files in the Documentation subtree, including Documentation/chapter_1/figure_1.jpg.

A pathspec that begins with a colon : has special meaning. In the short form, the leading colon : is followed by zero or more “magic signature” letters (which optionally is terminated by another colon :), and the remainder is the pattern to match against the path. The “magic signature” consists of ASCII symbols that are neither alphanumeric, glob, regex special characters nor colon. The optional colon that terminates the “magic signature” can be omitted if the pattern begins with a character that does not belong to “magic signature” symbol set and is not a colon.

In the long form, the leading colon : is followed by a open parenthesis (, a comma-separated list of zero or more “magic words”, and a close parentheses ), and the remainder is the pattern to match against the path.

A pathspec with only a colon means “there is no pathspec”. This form should not be combined with other pathspec.

top
The magic word top (magic signature: /) makes the pattern match from the root of the working tree, even when you are running the command from inside a subdirectory.

literal
Wildcards in the pattern such as * or ? are treated as literal characters.

icase
Case insensitive match.

glob
Git treats the pattern as a shell glob suitable for consumption by fnmatch(3) with the FNM_PATHNAME flag: wildcards in the pattern will not match a / in the pathname. For example, “Documentation/*.html” matches “Documentation/git.html” but not “Documentation/ppc/ppc.html” or “tools/perf/Documentation/perf.html”.

Two consecutive asterisks (“**”) in patterns matched against full pathname may have special meaning:

A leading “**” followed by a slash means match in all directories. For example, “**/foo” matches file or directory “foo” anywhere, the same as pattern “foo”. “**/foo/bar” matches file or directory “bar” anywhere that is directly under directory “foo”.

A trailing “/**” matches everything inside. For example, “abc/**” matches all files inside directory “abc”, relative to the location of the .gitignore file, with infinite depth.

A slash followed by two consecutive asterisks then a slash matches zero or more directories. For example, “a/**/b” matches “a/b”, “a/x/b”, “a/x/y/b” and so on.

Other consecutive asterisks are considered invalid.

Glob magic is incompatible with literal magic.

exclude
After a path matches any non-exclude pathspec, it will be run through all exclude pathspec (magic signature: !). If it matches, the path is ignored.

parent
A commit object contains a (possibly empty) list of the logical predecessor(s) in the line of development, i.e. its parents.

pickaxe
The term pickaxe refers to an option to the diffcore routines that help select changes that add or delete a given text string. With the –pickaxe-all option, it can be used to view the full changeset that introduced or removed, say, a particular line of text. See git-diff(1).

plumbing
Cute name for core Git.

porcelain
Cute name for programs and program suites depending on core Git, presenting a high level access to core Git. Porcelains expose more of a SCM interface than the plumbing.

pull
Pulling a branch means to fetch it and merge it. See also git-pull(1).

push
Pushing a branch means to get the branch’s head ref from a remote repository, find out if it is a direct ancestor to the branch’s local head ref, and in that case, putting all objects, which are reachable from the local head ref, and which are missing from the remote repository, into the remote object database, and updating the remote head ref. If the remote head is not an ancestor to the local head, the push fails.

reachable
All of the ancestors of a given commit are said to be “reachable” from that commit. More generally, one object is reachable from another if we can reach the one from the other by a chain that follows tags to whatever they tag, commits to their parents or trees, and trees to the trees or blobs that they contain.

rebase
To reapply a series of changes from a branch to a different base, and reset the head of that branch to the result.

ref
A name that begins with refs/ (e.g. refs/heads/master) that points to an object name or another ref (the latter is called a symbolic ref). For convenience, a ref can sometimes be abbreviated when used as an argument to a Git command; see gitrevisions(7) for details. Refs are stored in the repository.

The ref namespace is hierarchical. Different subhierarchies are used for different purposes (e.g. the refs/heads/ hierarchy is used to represent local branches).

There are a few special-purpose refs that do not begin with refs/. The most notable example is HEAD.

reflog
A reflog shows the local “history” of a ref. In other words, it can tell you what the 3rd last revision in this repository was, and what was the current state in this repository, yesterday 9:14pm. See git-reflog(1) for details.

refspec
A “refspec” is used by fetch and push to describe the mapping between remote ref and local ref.

remote-tracking branch
A ref that is used to follow changes from another repository. It typically looks like refs/remotes/foo/bar (indicating that it tracks a branch named bar in a remote named foo), and matches the right-hand-side of a configured fetch refspec. A remote-tracking branch should not contain direct modifications or have local commits made to it.

repository
A collection of refs together with an object database containing all objects which are reachable from the refs, possibly accompanied by meta data from one or more porcelains. A repository can share an object database with other repositories via alternates mechanism.

resolve
The action of fixing up manually what a failed automatic merge left behind.

revision
Synonym for commit (the noun).

rewind
To throw away part of the development, i.e. to assign the head to an earlier revision.

SCM
Source code management (tool).

SHA-1
“Secure Hash Algorithm 1”; a cryptographic hash function. In the context of Git used as a synonym for object name.

shallow repository
A shallow repository has an incomplete history some of whose commits have parents cauterized away (in other words, Git is told to pretend that these commits do not have the parents, even though they are recorded in the commit object). This is sometimes useful when you are interested only in the recent history of a project even though the real history recorded in the upstream is much larger. A shallow repository is created by giving the –depth option to git-clone(1), and its history can be later deepened with git-fetch(1).

symref
Symbolic reference: instead of containing the SHA-1 id itself, it is of the format ref: refs/some/thing and when referenced, it recursively dereferences to this reference. HEAD is a prime example of a symref. Symbolic references are manipulated with the git-symbolic-ref(1) command.

tag
A ref under refs/tags/ namespace that points to an object of an arbitrary type (typically a tag points to either a tag or a commit object). In contrast to a head, a tag is not updated by the commit command. A Git tag has nothing to do with a Lisp tag (which would be called an object type in Git’s context). A tag is most typically used to mark a particular point in the commit ancestry chain.

tag object
An object containing a ref pointing to another object, which can contain a message just like a commit object. It can also contain a (PGP) signature, in which case it is called a “signed tag object”.

topic branch
A regular Git branch that is used by a developer to identify a conceptual line of development. Since branches are very easy and inexpensive, it is often desirable to have several small branches that each contain very well defined concepts or small incremental yet related changes.

tree
Either a working tree, or a tree object together with the dependent blob and tree objects (i.e. a stored representation of a working tree).

tree object
An object containing a list of file names and modes along with refs to the associated blob and/or tree objects. A tree is equivalent to a directory.

tree-ish (also treeish)
A tree object or an object that can be recursively dereferenced to a tree object. Dereferencing a commit object yields the tree object corresponding to the revision’s top directory. The following are all tree-ishes: a commit-ish, a tree object, a tag object that points to a tree object, a tag object that points to a tag object that points to a tree object, etc.

unmerged index
An index which contains unmerged index entries.

unreachable object
An object which is not reachable from a branch, tag, or any other reference.

upstream branch
The default branch that is merged into the branch in question (or the branch in question is rebased onto). It is configured via branch.<name>.remote and branch.<name>.merge. If the upstream branch of A is origin/B sometimes we say “A is tracking origin/B”.

working tree
The tree of actual checked out files. The working tree normally contains the contents of the HEAD commit’s tree, plus any local changes that you have made but not yet committed.