Skip to content

Latest commit

 

History

10 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 

Repository files navigation

Git and GitHub (365 Data Science Course)

Course: Git and GitHub Provider: 365 Data Science

Course Link: https://365datascience.com/courses/git-and-github/


1. Course Introduction

Introduction to Git and GitHub

Git

Git is a distributed version control system that tracks changes in files and enables collaboration among developers.

GitHub

GitHub is a cloud-based platform for hosting Git repositories, collaborating with others, reviewing code, and managing software projects.


2. Introduction to Git

2.1 Installing Git

Download and install Git from:

https://git-scm.com/


2.2 Configuring Git

Check the installed version:

git --version

Display general help:

git --help

Display help for a specific command:

git help init

Configure your Git username:

git config --global user.name "My Name"

Configure your email address:

git config --global user.email "name@domain.com"

It is recommended to use the same email address as your GitHub account so commits are correctly associated with your profile.

Set the default editor:

git config --global core.editor "notepad"

Create a test file:

notepad testdocument.txt

View the current Git configuration (Press q to quit):

git config --list

2.3 Basic Git Commands

Initialize a Git repository:

git init

Check the repository status:

git status

Start tracking a file (Stage the file):

git add list.txt

Create a commit:

git commit -m "Create shopping list"

View commit history:

git log

2.4 Exploring Git Log

Check repository status:

git status

View changes in the working directory:

git diff

Stage changes:

git add list.txt

Commit the changes:

git commit -m "Added fruits and vegetables"

Display only the latest commit:

git log -1

2.5 Git Diff

Show differences between the working directory and the staging area:

git diff

Show differences between the staging area and the last commit:

git diff --staged

(Equivalent:)

git diff --cached

2.6 HEAD

Compare a previous commit with the current working tree:

git diff <commit-hash>

Example:

git diff 3cb2d5789aa

HEAD is a reference (pointer) to the currently checked-out commit, usually the latest commit on the current branch.

Restore a file from three commits earlier:

git checkout HEAD~3 -- list.txt

Restore the latest committed version of the file:

git checkout HEAD -- list.txt

Note: In modern Git, git restore is preferred over git checkout for restoring files.


2.7 Undoing Changes with Git Reset

Unstage a file without losing changes:

git reset list.txt

Move HEAD back one commit while keeping changes staged:

git reset HEAD~1 --soft

Move HEAD back one commit and unstage the changes while keeping the file contents:

git reset HEAD~1 --mixed

Move HEAD back one commit and discard all changes:

git reset HEAD~1 --hard

?? --hard permanently deletes uncommitted changes. Use it with caution.


2.8 Branching

Create a branch:

git branch dairy

List branches:

git branch

Create another branch:

git branch meat

Switch to a branch:

git checkout dairy

Return to the main branch:

git checkout master

Merge another branch into the current branch:

git merge meat

Newer Git versions use main instead of master as the default branch name.


2.9 Practice Exam


3. GitHub

3.1 Connecting a Local Repository to GitHub

Add a remote repository:

git remote add origin https://github.com/PythonJournalist/git_practice.git

Verify the remote:

git remote -v

Push the local repository:

git push origin master

If your default branch is main, use:

git push origin main

3.2 Cloning a Repository

Clone a repository:

git clone https://github.com/medical_dataset/data.git

Download changes from the remote repository:

git fetch

Download and merge changes:

git pull

4. Conclusion

This course introduced the fundamentals of Git and GitHub, including:

  • Installing and configuring Git
  • Creating repositories
  • Tracking and committing changes
  • Viewing history with git log
  • Comparing changes with git diff
  • Understanding HEAD
  • Undoing changes using git reset
  • Working with branches
  • Connecting to GitHub
  • Cloning, fetching, pulling, and pushing repositories

5. Course Exam

Completed.


Summary

This repository contains my notes while completing the Git and GitHub course from 365 Data Science. It covers the essential Git commands and GitHub workflows needed for version control and collaboration.

About

Course notes for Git and GitHub (365 Data Science Course)

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors