Skip to content

VenkataViswas/Github-Notes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

Git and GitHub Notes

What is Git?

Git is a version control system that allows developers to track changes, collaborate with others, and manage different versions of code over time. It's widely used for software development to handle projects efficiently.

Key Features of Git

  • Distributed: Every developer has a complete copy of the project’s history.
  • Branching and Merging: Enables easy branching and merging, making it ideal for collaboration.
  • Efficiency: Optimized for speed and efficient handling of large projects.

Basic Git Workflow

  1. Initialize Repository
    git init - Creates a new Git repository.

  2. Staging Changes
    git add <file> - Stages changes for commit.

  3. Committing Changes
    git commit -m "commit message" - Commits staged changes with a descriptive message.

  4. Pushing to Remote Repository
    git push origin <branch> - Pushes changes to a branch on a remote repository (like GitHub).

  5. Pulling Updates
    git pull origin <branch> - Fetches and integrates changes from a remote repository.

Important Git Commands

  • git status - Shows the status of your files in the working directory and staging area.
  • git log - Displays the commit history.
  • git diff - Shows the difference between the working directory and the staging area.
  • git branch - Lists branches; use git branch <branch_name> to create a new branch.
  • git checkout <branch> - Switches to the specified branch.

What is GitHub?

GitHub is a cloud-based platform for hosting Git repositories, enabling collaboration, version control, and open-source contributions. GitHub adds features like issue tracking, pull requests, and GitHub Actions (for CI/CD).

Key Features of GitHub

  • Remote Repositories: Host and access code from anywhere.
  • Collaboration: Share code, contribute via pull requests, and manage issues.
  • GitHub Actions: Automate workflows such as CI/CD, testing, and deployments.
  • Documentation: Use README files, wikis, and GitHub Pages for project documentation.

GitHub Workflow

  1. Clone a Repository
    git clone <repo_url> - Copies a remote repository to your local machine.

  2. Creating a New Repository on GitHub

    • Go to GitHub and click "New" to create a repository.
    • Set repository name, visibility (public/private), and initialize with a README if desired.
    • Copy the URL to push your local project to GitHub.
  3. Working with Pull Requests

    • Fork the repository to create a copy under your account.
    • Make changes, commit, and push them to your forked repository.
    • Open a Pull Request from your fork to the original repository to request merging changes.
  4. Creating Issues

    • Go to the "Issues" tab in a repository.
    • Describe the bug, feature, or task to manage collaboration and tracking.

Git and GitHub Glossary

  • Repository: A project or folder containing your code and its history.
  • Commit: A snapshot of changes made in the repository.
  • Branch: A parallel version of the repository allowing independent development.
  • Merge: Combines changes from one branch into another.
  • Pull Request (PR): Proposes changes to be merged into another branch (often used in open-source projects).
  • Fork: A copy of another repository under your account, often used to contribute to others’ projects.
  • Clone: A local copy of a remote repository.

Best Practices

  • Commit Often: Make frequent, meaningful commits with clear messages.
  • Use Branches: Create branches for new features or bug fixes to keep the main branch clean.
  • Write Good Commit Messages: Keep messages short but descriptive.
  • Pull Before Push: Regularly pull changes from the main branch to avoid merge conflicts.

Use Git and GitHub together to streamline collaboration, code review, and version control in your projects!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published