Changes

Jump to: navigation, search

DPS909 & OSD600 Winter 2017 - Git Walkthrough

3,711 bytes added, 12:23, 11 January 2017
no edit summary
branches description info refs
</pre>
 
NOTE: normally we <code>git clone</code> to clone (also known as fork) a repository. We'll do that in a bit.
 
===Step 3: adding files===
 
Let's inspect the current status of our repo:
 
<pre>
$ git status
On branch master
 
Initial commit
 
Untracked files:
(use "git add <file>..." to include in what will be committed)
 
.editorconfig
.eslintignore
.gitattributes
.gitignore
.hound.yml
.houndignore
.travis.yml
CHANGELOG.md
CNAME
CONTRIBUTING.md
Gemfile
Gemfile.lock
Gruntfile.js
ISSUE_TEMPLATE.md
LICENSE
README.md
_config.yml
bower.json
composer.json
dist/
docs/
grunt/
js/
nuget/
package.js
package.json
sache.json
scss/
 
nothing added to commit but untracked files present (use "git add" to track)
</pre>
 
Our '''Working Directory''' (i.e., <code>bootstrap-4.0.0-alpha.6/</code>) has a lot of files and folders that are '''untracked''' (i.e., git has no record of them in its history).
 
We include a file in git's history by adding it to the '''index''' (also known as the '''staging area'''). Let's add the <code>README.md</code> file:
 
<pre>
$ git add README.md
$ git status
On branch master
 
Initial commit
 
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
 
new file: README.md
 
Untracked files:
(use "git add <file>..." to include in what will be committed)
 
.editorconfig
.eslintignore
.gitattributes
.gitignore
.hound.yml
.houndignore
.travis.yml
CHANGELOG.md
CNAME
CONTRIBUTING.md
Gemfile
Gemfile.lock
Gruntfile.js
ISSUE_TEMPLATE.md
LICENSE
_config.yml
bower.json
composer.json
dist/
docs/
grunt/
js/
nuget/
package.js
package.json
sache.json
scss/
</pre>
 
This time <code>git status</code> continues to report our '''Untracked files''', but also includes a new section: '''Changes to be committed'''. The <code>README.md</code> file has been added to the staging area, and is ready to be commited to git's history.
 
We record a '''snapshot''' of our files by committing the staging area's contents:
 
<pre>
$ git commit -m "Added README file"
[master (root-commit) 03c9551] Added README file
1 file changed, 135 insertions(+)
create mode 100755 README.md
</pre>
 
Let's look at our status again:
 
<pre>
git status
On branch master
Untracked files:
(use "git add <file>..." to include in what will be committed)
 
.editorconfig
.eslintignore
.gitattributes
.gitignore
.hound.yml
.houndignore
.travis.yml
CHANGELOG.md
CNAME
CONTRIBUTING.md
Gemfile
Gemfile.lock
Gruntfile.js
ISSUE_TEMPLATE.md
LICENSE
_config.yml
bower.json
composer.json
dist/
docs/
grunt/
js/
nuget/
package.js
package.json
sache.json
scss/
 
nothing added to commit but untracked files present (use "git add" to track)
</pre>
 
Here's how things stand now:
* Our working copy continues to have lots of untracked files and folders. However, <code>README.md</code> is not among them
* Our staging area is empty
* Our git repo has 1 commit that added 1 file, which we can see if we use <code>git log</code>
 
<pre>
$ git log
commit 03c95518ce08f59e850409a2d82bacad110151a1
Author: David Humphrey (:humph) david.humphrey@senecacollege.ca <david.humphrey@senecacollege.ca>
Date: Wed Jan 11 11:07:09 2017 -0500
 
Added README file
</pre>
 
Every record in our history is called a '''commit''', and it's a snapshot of our repo's filesystem along with metadata:
* a unique commit identifier (SHA-1), in this case <code>03c95518ce08f59e850409a2d82bacad110151a1</code>, which is often shortened to the first 7 characters: <code>03c9551</code>.
* an author, every commit is done by somebody, and we want to keep track of this
* a date and time
* a commit message, describing what this commit changed, added, deleted, etc.
 
 
 
 
* Client Server (SVN) and Distributed (Git)

Navigation menu