Skip to content

c4arl0s/2TheBasicsRysGitTutorial

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 

Repository files navigation

  1. 1. Create the example Site
  2. 2. Initialize the Git Repository
  3. 3. View the repository status
  4. 4. Stage a snapshot
  5. 5. Commit the Snapshot
  6. 6. View the repository History
  7. 7. Configure Git
  8. 8. Create New HTML files
  9. 9. Stage the New Files
  10. 10. Commit The new Files
  11. 11. Modify the HTML Pages
  12. 12. Stage and Commit the Snapshot
  13. 13. Explore the Repository
  14. 14. Conclusion
  15. 15. Quick Reference

This module explores the fundamental Git workflow:

  1. creating a repository,
  2. staging and committing snapshots,
  3. configuring options,
  4. viewing the state of a repository.
<!DOCTYPE html>
<html lang="en">
<head>
  <title>A Colorful Website</title>
  <meta charset="utf-8" />
</head>
<body>
  <h1 style="color: #07F">A Colorful Website</h1>
  <p>This is a website about color!</p>    
  
  <h2 style="color: #C00">News</h2>
  <ul>
    <li>Nothing going on (yet)</li>
  </ul>
</body>
</html>
$ cd /Users/carlossantiagocruz/SWIFT-PROGRAMMING/RysGitTutorial
  • then initialize
$ git init
  • output
Initialized empty Git repository in /Users/carlossantiagocruz/Documents/SWIFT-PROGRAMMING/RysGitTutorialRepository/.git/
$ git status
On branch master

No commits yet

Untracked files:
  (use "git add <file>..." to include in what will be committed)
	index.html

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

- Git does not automatically track files because there are often project files that we don't want to keep under revision control.

Screenshot 2023-11-26 at 11 58 19 a m
  • tell git to start tracking index.html
$ git add index.html
$ git status
  • output
On branch master

No commits yet

Changes to be committed:
  (use "git rm --cached <file>..." to unstage)
	new file:   index.html
  1. A snapshot represents the state of your project at a given point in time.
  2. Git's term for creating a snapshot is called staging
  3. Staging give us the opportunity to group related changes into distinct snapshots.
Screenshot 2023-11-26 at 11 45 44 a m
$ git commit

Screen Shot 2020-05-22 at 12 55 58

$ git log
  • output
commit 6a442fcc4ab51362713f09ed5eadc7af767db833
Author: c4arl0s <c.santiago.cruz@gmail.com>
Date:   Fri May 22 12:54:21 2020 -0500

    Create index page for the message
$ git config --global user.name "your name"
$ git config --global user.email your.email@example.com

[re-read the book if you want more information]

  • orange.html
<!DOCTYPE html>
<html lang="en">
<head>
  <title>The Orange Page</title>
  <meta charset="utf-8" />
</head>
<body>
  <h1 style="color: #F90">The Orange Page</h1>
  <p>Orange is so great it has a
  <span style="color: #F90">fruit</span> named after it.</p>
</body>
</html>
  • blue.html
<!DOCTYPE html>
<html lang="en">
<head>
  <title>The Blue Page</title>
  <meta charset="utf-8" />
</head>
<body>
  <h1 style="color: #00F">The Blue Page</h1>
  <p>Blue is the color of the sky.</p>
</body>
</html>
$ git add orange.html blue.html
$ git status
  • output
On branch master
Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
	new file:   blue.html
	new file:   orange.html

Screen Shot 2020-05-22 at 13 21 50

$ git commit -m "add blue and orangle html file"

Screen Shot 2020-05-22 at 13 47 10

  • add this at the end of index.html
<h2>Navigation</h2>
<ul>
  <li style="color: #F90">
    <a href="orange.html">The Orange Page</a>
  </li>
  <li style="color: #00F">
  • add this at the end of orange.html
<p><a href="index.html">Return to home page</a></p>
$ git status
  • output
On branch master
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
	modified:   index.html
	modified:   orange.html

no changes added to commit (use "git add" and/or "git commit -a")
$ git add index.html orange.html blue.html 
  • status
On branch master
Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
	modified:   index.html
	modified:   orange.html
  • commit
$ git commit -m "Add navigation links"
[master 453c8a4] Add navigation links
 2 files changed, 10 insertions(+), 1 deletion(-)

- Note that the red circle, which represent the current commit, automatically moves forward every time we commit a new snapshot.

Screen Shot 2020-05-22 at 16 55 24

$ git log --oneline
  • output
453c8a4 Add navigation links
1047951 t Add blue an orange html files
6a442fc Create index page for the message
  • Condensing output to a single line is a great way to get a high-level overview of a repository
  • Another useful configuration is to pass a filename to git log:
1047951 t Add blue an orange html files
  • This display only the blue.html history.
  • Notice that the initial Create index page commit is missing, since blue.html didn't exist in that snapshot.

Screen Shot 2020-05-22 at 17 01 45

$ git init

Create a git repository in the current folder.

$ git status

View the status of each file in a repository.

$ git add fileName

Stage a file for the next commit.

$ git commit

Commit the staged files with a descriptive message.

$ git log

View a repository's commit history.

$ git config --global user.name "<nameOfTheUser>"

Define the author name to be used in all repositories.

$ git config --global user.email <email>

Define the author email to be used in all repositories.

About

2 The Basics Rys Gi tTutorial

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors