Git Intro

Git Intro

For full blog, click here

Version Control System (VCS)

A system that saves multiple versions of a file. This allows tracking of changes, reverting back to a previous version, tracking modifications along with their creators, and comparing changes.

Git

Let’s Get Started

Download Git:

  1. Install as a package
  2. Install via another installer
  3. Download and compile the source code

If you would like Graphical User Interface (GUI) tools, visit this link for options

Initial Customization

Configuration of Variables: Use Git tool git config Identity Setting: set your username and email address to be used for every Git commit

In the terminal type:

  git config --global user.name "Jane Smith"

  git config --global user.email "example@email.com"

Default Text Editor: Git uses your system’s default editor, to switch editors, type into your command line:

  '$ git config --global core.editor (name of editor)'

Check Your Setting: Use the ‘git config –list’ command

Setting Up a Git Repository

Importing To import an existing project or directory into Git, type into your terminal:

  1. Switch to target project’s directory: $ cd test (cd = change directory)
  2. Use the git init command: $ git init
  3. Start tracking these files:
    • $ git add *.c
    • $ git add LICENSE
    • $ git commit -m “any message here”

Cloning Clone an existing repository from a particular server with clone command: $ git clone ‘the repository’s URL’

Workflow

Local Repository Structure:

  1. Working Directory: The actual files reside here
  2. Index: The area used for staging
  3. Head: Points to the most recent commit

Saving Changes

The Life cycle of File Status

unmodified ➡️ edit the file ➡️ modified ➡️ stage the file ➡️ staged ➡️ commit the file ➡️ unmodified

Tracking and Staging a New File

Committing a File

After staging, commit the changes and write a commit message of what you did

Pushing Changes

This command pushes changes from the local “master” branch to the remote repository named “origin”

Stashing Changes

Remote Repositories

Versions of a project found online or on a network - push and pull data from these repositories!

Seeing Your Remotes

Return home