GithubHelp home page GithubHelp logo

git-workshop's Introduction

Git - Workshop

Introduction

This repo serves as a guideline for introducing how git works for beginners. Feel free to use this however you want to. All credit goes to the original authors (see References below). In this guide, there will be several terms used to convey meaning for an instruction or definition.

Content

  1. Version Control & Git
  2. Preparation / Installation
  3. Common Git Commands
  4. Advanced Git Commands
  5. References

Version Control & Git

Version control is a practice of software code management. One can view it as a perspective of accounting in finance. Every bit of transaction is somehow being recorded (i.e. amount and date). In software development, version control is the accounting practice. Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.

Preparation / Installation

To use git, you would have to install it on your local machine.

Go to Git - Downloads page and follow the instructions provided according to your machine's OS and architecture (x64 or x86).

Verify your installation by opening your terminal and running the command git --version (or git -v for short).

Common Git Commands

The following commands will be used primarily for your day-to-day use. There might be other commands that are not included in this README. You are encouraged to refer to the official Git Documentation for further information. You may also refer to their quick guides: GitHub Cheat Sheet | Visual Git Cheat Sheet

git init

This command creates an empty Git repository. This is usually the first required step for versioning your files.

Command: git init

git clone

Clones a repository into a new directory.

Command: git clone [PATH]

git status

Show the working tree status. This command is typically paired with git add (executed after it) to see the changes in files before executing git commit (See below)

Command: git status

git fetch / git pull

Download objects and refs from another repository

Command: git fetch

Fetch from and integrate with another repository or a local branch

Command: git pull

Difference between git fetch and git pull is primarily that git fetch only retrieves the information on what has been changed since (you can look at it like syncing device), whereas git pull retrieves the information and applies the changes on your local repo.

git add (git stage)

Add file contents to the index. The term 'stage' and its equivalent tenses usually refers to the same idea.

Command: git add [OPTIONS]

git commit

Record changes to the repository. This command will make the current branch that you are working on to have the latest 'entry'.

Command: git commit

git push

Update remote refs along with associated objects.

Command: git push [OPTIONS]

git branch

List, create, or delete branches. This is particularly useful if you are planning to make use of the Git branching strategies (Advanced topic, see below).

Command: git branch [OPTIONS]

git checkout

Switch branches or restore working tree files. Depending on your workflow, you are required to not mix your tasks under a single branch especially if you are involved in multiple features or modules.

Command: git checkout [OPTIONS]

Advanced Git Commands

git merge

Join two or more development histories together. This command is particularly common in applying the changes of a code from a branch (i.e. feature-branch) into another branch (i.e. production-branch).

Command: git merge [OPTIONS]

git rebase

Reapply commits on top of another base tip. This command makes your branch more streamlined (cleaner flow). However this is a very subjective opinion and should be used with the consensus of your team or organisation.

Command: git rebase [OPTIONS]

git stash

Stash the changes in a dirty working directory away. This command is very powerful and useful as to preserve changes without having to commit it (think of it like saving a draft before publishing).

Command: git stash [COMMNAD] [OPTIONS]

References

  1. Official Git website | https://git-scm.com/
  2. Git and GitHub for Beginners - Crash Course | https://youtu.be/RGOj5yH7evk?si=dh6Mno4YeG6zzfQj
  3. Git Workflow - Atlassian Git Tutorial | https://www.atlassian.com/git/tutorials/comparing-workflows

git-workshop's People

Contributors

iqmalsb avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.