Git/Github
Git
Git is a distributed version control system that allows us to track changes, collaborate, and manage different versions of our code or project. It is designed to handle everything from small to large-scale projects with speed and efficiency.
Git Commands:
git init: Initializes a new Git repository in the current directory.git initgit clone <repository_url>: Clones (downloads) a repository from a remote server to your local machine.git clone <https://github.com/example/repository.git>git commit -m "<message>": Commits the changes in the staging area with a descriptive message.git commit -m "Add new feature"git status: Shows the status of the working directory and staging area.git statusgit diff: Displays the differences between the working directory and the staging area.git diffgit push: Pushes committed changes to a remote repository.git push origin maingit pull: Fetches and merges changes from a remote repository to your local repository.git pull origin maingit branch: Lists all branches in the repository.git branchgit checkout <branch_name>: Switches to a specific branch.git checkout feature-branchgit merge <branch_name>: Merges a branch into the current branch.git merge feature-branchgit remote add <remote_name> <repository_url>: Adds a remote repository. (Github or Gitlab)git remote add origin <https://github.com/example/repository.git>git remote -v: Lists all the remote repositories.git remote -vgit log: Displays a log of commits.git loggit reset <commit_id>: Resets the repository to a specific commit.git reset HEAD~1git stash: Temporarily saves changes that are not ready to be committed.git stashgit tag <tag_name>: Creates a new tag for a specific commit.git tag v1.0.0git fetch: Fetches changes from a remote repository without merging.git fetch origin
Github
GitHub is a web-based hosting service built around Git. It provides a platform for storing, managing, and sharing Git repositories online. It adds a social aspect to Git, allowing developers to collaborate on projects, review code, track issues, and manage project documentation.
GitHub Commands:
git remote add origin <repository_url>: Connects your local repository to a remote GitHub repository.git remote add origin <https://github.com/example/repository.git>git push -u origin <branch_name>: Pushes the branch to the remote repository, establishing an upstream connection.git push -u origin maingit pull origin <branch_name>: Fetches and merges changes from a remote GitHub repository to your local repository.git pull origin maingit clone <repository_url>: Clones a GitHub repository to your local machine.git clone <https://github.com/example/repository.git>git fork: Creates a copy (fork) of a repository on your GitHub account. This command is performed on the GitHub website by clicking the "Fork" button on the repository page.git pull request: Initiates a pull request on GitHub to propose changes from your branch to the original repository. This command is performed on the GitHub website by clicking the "New pull request" button on your forked repository page.git merge <pull_request_branch>: Merges a pull request into the main branch of the repository. This command is performed on the GitHub website by clicking the "Merge pull request" button on the pull request page.git issues: Lists all issues (bugs, tasks, feature requests) in a GitHub repository.This command is performed on the GitHub website by visiting the "Issues" tab of the repository.
git branch -d <branch_name>: Deletes a branch in your local repository.git branch -d feature-branchgit push origin --delete <branch_name>: Deletes a branch in a remote GitHub repository.git push origin --delete feature-branchgit remote set-url origin <new_repository_url>: Changes the URL of the remote repository.git remote set-url origin <https://github.com/new/example/repository.git>