Learning objectives

  • What is Github?
  • Connect Git with Github
  • Create a repository on Github
  • Connect local and push the changes on Github
  • Clone a repository

What is Github?

GitHub is a code hosting platform using the Git version control system. It lets you and others work together on projects from anywhere

Connect Git with Github

 We need to authenticate with GitHub using either HTTPS or SSH (Secure Shell Protocol). Since SSH is more secure, this is the recommended path.

  1. Generate an SSH key and add it to the ssh-agent
  2. Add your SSH key to your GitHub account
  3. Test your SSH connection

Create a repository on Github

Will be two ways to create a new repository:

Connect local and push the changes on Github

Clone a repository

git clone git@github.com:pazteddy/patrones_diseno_java.git

More than 90% of software projects in the world use Git.

 

Almost every job description for software developers mentions Git as a requirement.

Is a Version Control System

Is a distributed VCS

centralized

distributed

Workflow

working directory

git repository

staging area

Workflow

working directory

git repository

staging area

file1

file2

Workflow

working directory

git repository

staging area

git add file1 file2

file1

file2

file1

file2

Workflow

working directory

git repository

staging area

git commit -m "Add file1 and file2"

file1

file2

git log:

Add file1 and file2

Workflow

working directory

git repository

staging area

file1

file2

git log:

Add file1 and file2

Workflow

working directory

git repository

staging area

git add file1

file1

file2

file1

git log:

Add file1 and file2

Workflow

working directory

git repository

staging area

git commit -m "Update file1"

file1

file2

git log:

Add file1 and file2

Update file1

Workflow

working directory

git repository

staging area

file1

file2

git log:

Add file1 and file2

Update file1

Workflow

working directory

git repository

staging area

git add file2

file1

file2

file2

git log:

Add file1 and file2

Update file1

Workflow

working directory

git repository

staging area

git commit -m "Delete file2"

file1

git log:

Add file1 and file2

Update file1

Delete file2

Branching

main

HEAD

Branching

main

HEAD

Branching

main

HEAD

Branching

main

feature

HEAD

Branching

main

feature

HEAD

Branching

main

feature

HEAD

Branching

main

HEAD

feature

Branching

main

HEAD

feature

Fast Forward

If branches have not diverge

Branching

main

HEAD

feature

Branching

main

HEAD

feature

Branching

main

feature

HEAD

Branching

main

HEAD

feature

Branching

main

HEAD

feature

Branching

feature

3 way merging

If branches have have diverged

main

HEAD

merge commit

Branching

feature

Rebase

Put your new commits on top of the history

main

HEAD

Branching

feature

Rebase

Put your new commits on top of the history

main

HEAD

Branching

feature

Rebase

Put your new commits on top of the history

main

HEAD

Branching

feature

Now Merge with Fast Forward

main

HEAD

Resources

Made with Slides.com