Code Monkey home page Code Monkey logo

first_repo's Introduction

Introduction to GitHub Course

1. Introduction to GitHub

What is GitHub?

  • Definition: GitHub is a web-based platform that uses Git, a distributed version control system, for tracking changes in source code during software development.
  • Importance: Essential for collaboration, allowing multiple people to work on a project simultaneously. Widely used in open-source projects and professional development.

Basic Concepts of Git and GitHub

  • Version Control System (VCS): Tracks changes, allows reverting to previous states, and manages modifications by multiple people.
  • Repositories:
    • Local Repository: On your computer, where changes are made.
    • Remote Repository: Stored on GitHub's server for sharing and collaborating.
  • Commits: Records of changes to the repository, each with a unique ID.
  • Branches: Different versions of the repository. Main branch is usually main or master.
  • Merges: Combining changes from different branches.
  • Pull Requests: Requests for someone to review and pull in your contribution.
  • Forks and Clones:
    • Fork: A GitHub copy of a repository for making changes without affecting the original.
    • Clone: Copying the repository to your local machine.

2. Setting Up

Installing Git

  • Windows: Download and install from Git's website.
  • Mac: Use Homebrew (brew install git) or Git's website.
  • Linux: Install via the distribution's package manager (e.g., sudo apt-get install git for Ubuntu).

Setting Up GitHub Account

Installing Visual Studio Code

Configuring Git with VS Code

  • Open VS Code terminal (Ctrl+`).
  • Set username: git config --global user.name "Your Name".
  • Set email: git config --global user.email "[email protected]".

3. Basic Operations

Creating a New Repository on GitHub

  • On GitHub: Click 'New repository' > Name your repository > Initialize with a README (optional) > Create repository.
  • Example: Creating "MyFirstRepo".

Cloning a Repository in VS Code

  • Command: git clone https://github.com/username/MyFirstRepo.git.
  • Clone via VS Code's source control panel.

Basic Git Commands

  • git add <filename> or git add . (to add all changes).
  • git commit -m "Commit message".
  • git push (to push to remote repository).
  • git pull (to update local repository).
  • git branch <branchname> (to create a new branch).
  • git checkout <branchname> (to switch branches).

Making Changes and Committing

  • Editing Files: Edit files in VS Code.
  • Staging Changes: Use git add.
  • Committing Changes: git commit -m "Your message".
  • Pushing to GitHub: git push.

Branching and Merging

  1. Create and Switch to the New Branch Use the following command to create and switch to your new branch:

    git branch new-branch-name
    git checkout new-branch-name

    Replace new-branch-name with your desired branch name.

  2. Make Your Changes Edit, add, or delete files in your project as needed.

  3. Stage Your Changes for Commit

    git add .

    This command stages all your changes for the next commit.

  4. Commit the Changes

    git commit -m "Describe your changes"

    Replace Describe your changes with a message describing what changes you've made.

  5. Push the New Branch to the Remote Repository

    git push -u origin new-branch-name

    Replace new-branch-name with the name of your new branch.

  6. Switch to the Main Branch

    git checkout main
  7. Pull the Latest Changes from Main

    git pull origin main

    This ensures you have the latest changes from the remote main branch.

  8. Merge the New Branch into Main

    git merge new-branch-name

    Replace new-branch-name with your branch's name. Resolve any merge conflicts if they arise.

  9. Push the Merged Changes to Remote

    git push origin main

Remember to replace new-branch-name and main with the actual names of your branches. This guide will help you create a new branch, make commits, and merge it back into the main branch.

first_repo's People

Contributors

roberalcaraz avatar

Stargazers

Elisabet Verger-Miralles 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.