Difference between revisions of "Learning Git (1)"

From Wiki @ Karl Jones dot com
Jump to: navigation, search
(Terminology)
(Typical process)
 
(2 intermediate revisions by the same user not shown)
Line 24: Line 24:
  
 
* https://git-scm.com/book/en/v2/Getting-Started-The-Command-Line
 
* https://git-scm.com/book/en/v2/Getting-Started-The-Command-Line
 +
 +
== Getting a git repository ==
 +
 +
You can get a Git project using two main approaches.
 +
 +
* The first takes an existing project or directory and imports it into Git.
 +
* The second clones an existing Git repository from another server.
 +
 +
=== Initializing a Repository in an Existing Directory ===
 +
 +
If you’re starting to track an existing project in Git, you need to go to the project’s directory and type:
 +
 +
<nowiki>$ git init</nowiki>
 +
 +
This creates a new subdirectory named .git that contains all of your necessary repository files – a Git repository skeleton.
 +
 +
At this point, nothing in your project is tracked yet. (See Git Internals for more information about exactly what files are contained in the .git directory you just created.)
 +
 +
If you want to start version-controlling existing files (as opposed to an empty directory), you should probably begin tracking those files and do an initial commit. You can accomplish that with a few git add commands that specify the files you want to track, followed by a git commit:
 +
 +
<nowiki>$ git add *.c
 +
$ git add LICENSE
 +
$ git commit -m 'initial project version'</nowiki>
 +
 +
Source: https://git-scm.com/book/en/v2/Git-Basics-Getting-a-Git-Repository
 +
 +
== Typical process ==
 +
 +
* [[git pull]]
 +
* git add
 +
* git commit
 +
* git push
  
 
== Terminology ==
 
== Terminology ==

Latest revision as of 07:46, 25 August 2016

This article introduces Git for the beginner.

Requirements

Learning and using Git requires:

Git hosting services

See GitHub.

Git clients

See Git client and GitHub Desktop.

Git servers

See Git server.

Command line

Getting a git repository

You can get a Git project using two main approaches.

  • The first takes an existing project or directory and imports it into Git.
  • The second clones an existing Git repository from another server.

Initializing a Repository in an Existing Directory

If you’re starting to track an existing project in Git, you need to go to the project’s directory and type:

$ git init

This creates a new subdirectory named .git that contains all of your necessary repository files – a Git repository skeleton.

At this point, nothing in your project is tracked yet. (See Git Internals for more information about exactly what files are contained in the .git directory you just created.)

If you want to start version-controlling existing files (as opposed to an empty directory), you should probably begin tracking those files and do an initial commit. You can accomplish that with a few git add commands that specify the files you want to track, followed by a git commit:

$ git add *.c
$ git add LICENSE
$ git commit -m 'initial project version'

Source: https://git-scm.com/book/en/v2/Git-Basics-Getting-a-Git-Repository

Typical process

Terminology

See also

External links

GitHub links:

General links:

June 06, 2013

Videos:

Bonus video: