Skip to content

Latest commit

 

History

History
101 lines (75 loc) · 4.02 KB

github-basics.md

File metadata and controls

101 lines (75 loc) · 4.02 KB

🐙 Git and GitHub: Deployment and Collaboration Hub

Git and GitHub are essential for collaboration and version control. They empower developers to work together on projects, track changes, and deploy code seamlessly. Here's how to get started:

🐙 Git and GitHub: The Developer's Playground

Getting Started with Git

  1. Install Git: Download and install Git for Windows from the official Git website.

  2. Configure Git: Open Git Bash and set your name and email using these commands:

    git config --global user.name "Your Name"
    git config --global user.email "[email protected]"
  3. Create the Repository: Start by creating a new repository on GitHub. Click "New" and follow the prompts.

    GitHub New Repository

  4. Clone the Repository: Copy the repository URL from the "Code" button and follow these steps to clone it to your local machine:

    • Open your terminal or command prompt.
    • Run:
      git clone URL-Goes-Here
  5. Start Coding: Open the cloned repository in your favorite code editor, such as Visual Studio Code. It's just like working with a regular folder. Make changes to files, create or delete folders, and let your creativity flow.

  6. Stage Your Changes: You need to let git know what changes you made. To add your changes to the staging area, type:

    git add <file-name-or-directory>

    You can use git add . to add all the changes. To check what changes are staged, run:

    git status

    In the output, the file names in green are the staged changes.

  7. Commit Changes: Once you have added your changes to the staging area, commit them by typing:

    git commit -m "<commit message>"

    Use a meaningful message describing what changes were made.

  8. Push Changes: Upload your changes to the GitHub repository by typing:

    git push

    If your branch isn't set up, check the output in the command line. It may have a message like:

    git push --set-upstream origin <branch-name>

    Once you've set your upstream, you can use git push for all future uploads to this branch.

  9. Pull Changes: To update your local machine with changes made elsewhere, run:

    git pull
  10. Create a Pull Request: If you want to suggest changes to someone else's repository, create a pull request via the "Pull request" button on their repository page.

  11. Merge Your Changes: The repository owner can merge your changes by clicking the "Merge pull request" button.

Additional GitHub Features

Branching Strategy

Branching allows you to work on different features or fixes simultaneously. Here’s a basic workflow:

  • Create a New Branch:
    git checkout -b <branch-name>
  • Switch to an Existing Branch:
    git checkout <branch-name>
  • Merge a Branch: First, switch to the branch you want to merge into (usually main or master), then:
    git merge <branch-name>

GitHub Pages

Deploy your static websites directly from your GitHub repository:

  • Enable GitHub Pages: Go to the repository settings and select the source branch for GitHub Pages.
  • Push Your Website Code: Any changes pushed to the source branch will automatically be deployed.

GitHub Actions

Automate your workflow with GitHub Actions:

  • Create a Workflow: Define your CI/CD pipeline in a .github/workflows directory within your repository.
  • Automate Tasks: From running tests to deploying code, GitHub Actions can handle it.

Collaborating with Teams

  • Invite Collaborators: Add team members to your repository for seamless collaboration.
  • Code Reviews: Use pull requests for code reviews and feedback.