Git: Difference between revisions

From HaFrWiki42
Jump to navigation Jump to search
Line 44: Line 44:
| width="225" | [https://www.kernel.org/pub/software/scm/git/docs/git-status.html git status]
| width="225" | [https://www.kernel.org/pub/software/scm/git/docs/git-status.html git status]
| width="225" | Store away (stash)
| width="225" | Store away (stash)
| width="225" | [https://www.kernel.org/pub/software/scm/git/docs/git-stash git stash]
| width="225" | [https://www.kernel.org/pub/software/scm/git/docs/git-stash.html git stash]
|}
|}
<br>
<br>

Revision as of 19:47, 6 July 2017

Git [1], is a distributed revision control and source code management (SCM) system with an emphasis on speed. Initially designed and developed by Linus Torvalds for Linux kernel development, Git has since been adopted by many other projects. Every Git working directory is a full-fledged repository with complete history and full revision tracking capabilities, not dependent on network access or a central server.

Stages

This is the main thing to remember about Git if you want the rest of your learning process to go smoothly. Git has three main states that your files can reside in:

  • Committed,
    Committed means that the data is safely stored in your local database.
  • Modified,
    Modified means that you have changed the file but have not committed it to your database yet.
  • Staged,
    Staged means that you have marked a modified file in its current version to go into your next commit snapshot.

This leads us to the three main sections of a Git project: the Git directory, the working directory, and the staging area.

  • Git directory
    The Git directory is where Git stores the metadata and object database for your project. This is the most important part of Git, and it is what is copied when you clone a repository from another computer.
  • Working directory
    The working directory is a single checkout of one version of the project. These files are pulled out of the compressed database in the Git directory and placed on disk for you to use or modify.
  • Staging area
    The staging area is a simple file, generally contained in your Git directory, that stores information about what will go into your next commit. It’s sometimes referred to as the index, but it’s becoming standard to refer to it as the staging area.

The basic Git workflow goes something like this:

  1. Modify files in your working directory.
  2. Stage the files, adding snapshots of them to your staging area.
  3. Commit, which takes the files as they are in the staging area and stores that snapshot permanently to your Git directory.

Setup

To setup git [2]

Username

First you need to tell git your name, so that it can properly label the commits you make.

 # Sets the default name for git to use when you commit.
 $ git config --global user.name "harm"

Email

Git saves your email address into the commits you make. We use the email address to associate your commits with your GitHub [3][4] account. <syntaxhighlight lang="bash" >

  1. Sets the default email account for git when you commit

$ git config --global user.email "h.frielink@<you-server-name>" </syntaxhighlight>

Cheat Sheet

Always handy are Cheat Sheets [5].

Information Tools
Status Repo git status Store away (stash) git stash


Create & Clone Add & Remove
Create new repo git init Add changes to INDEX git add <filename>
Clone local repo git clone /path Add all changes to INDEX git add *
Clone remote repo git clone username@host:/path/to/repo Remove / Delete git rm <filename>


Commit & Synchronize Branches
Commit changes git commit -m "Message" Create new branch git checkout -b <branch>
i.e.: git checkout feature-x
Push changes to remote repo git push origin master Switch to master branch git checkout master
Connect local repo to remote repo git remote add origin <server> Delete branch git branch -d <branch>
Update local repo with remote changes git pull push branch to remote repo git push origin <branch>


Merge Tagging
Merge changes from another branch git merge <branch> Create tag git tag <tag> <commit-ID>
View changes between 2 branches git diff <src-branch> <trg-branch> Get commit IDs git log

See also

top

External

  • GitHub is the best place to share code with friends, co-workers, classmates, and complete strangers. Over eight million people use GitHub to build amazing things together.
    • Guides GitHub, Basic Information (Guides) to Git and the implementation of Git on GitHub.
    • Help GitHub, The best place to look with a massive number of categories and help. A must if you are looking for something.
  • Cloudforge, Free Git repository Website for all your code.

Internal

  • GitHub, information on the GitBub, How to use, How to get information and more.

Tutorials

Reference

top

  1. Wikipedia Git-description, Git Software
  2. help-github, Setup.
  3. GitHub.com, Git-Repository Website for Open Source Projects
  4. GitHub, Help, Guides and more on using GitHub.
  5. Roger Dudler, Sheet Cheat