├── .github ├── FUNDING.yml └── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── SECURITY.md └── git command.txt /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: [benzocv] 4 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Desktop (please complete the following information):** 27 | - OS: [e.g. iOS] 28 | - Browser [e.g. chrome, safari] 29 | - Version [e.g. 22] 30 | 31 | **Smartphone (please complete the following information):** 32 | - Device: [e.g. iPhone6] 33 | - OS: [e.g. iOS8.1] 34 | - Browser [e.g. stock browser, safari] 35 | - Version [e.g. 22] 36 | 37 | **Additional context** 38 | Add any other context about the problem here. 39 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | We as members, contributors, and leaders pledge to make participation in our 6 | community a harassment-free experience for everyone, regardless of age, body 7 | size, visible or invisible disability, ethnicity, sex characteristics, gender 8 | identity and expression, level of experience, education, socio-economic status, 9 | nationality, personal appearance, race, religion, or sexual identity 10 | and orientation. 11 | 12 | We pledge to act and interact in ways that contribute to an open, welcoming, 13 | diverse, inclusive, and healthy community. 14 | 15 | ## Our Standards 16 | 17 | Examples of behavior that contributes to a positive environment for our 18 | community include: 19 | 20 | * Demonstrating empathy and kindness toward other people 21 | * Being respectful of differing opinions, viewpoints, and experiences 22 | * Giving and gracefully accepting constructive feedback 23 | * Accepting responsibility and apologizing to those affected by our mistakes, 24 | and learning from the experience 25 | * Focusing on what is best not just for us as individuals, but for the 26 | overall community 27 | 28 | Examples of unacceptable behavior include: 29 | 30 | * The use of sexualized language or imagery, and sexual attention or 31 | advances of any kind 32 | * Trolling, insulting or derogatory comments, and personal or political attacks 33 | * Public or private harassment 34 | * Publishing others' private information, such as a physical or email 35 | address, without their explicit permission 36 | * Other conduct which could reasonably be considered inappropriate in a 37 | professional setting 38 | 39 | ## Enforcement Responsibilities 40 | 41 | Community leaders are responsible for clarifying and enforcing our standards of 42 | acceptable behavior and will take appropriate and fair corrective action in 43 | response to any behavior that they deem inappropriate, threatening, offensive, 44 | or harmful. 45 | 46 | Community leaders have the right and responsibility to remove, edit, or reject 47 | comments, commits, code, wiki edits, issues, and other contributions that are 48 | not aligned to this Code of Conduct, and will communicate reasons for moderation 49 | decisions when appropriate. 50 | 51 | ## Scope 52 | 53 | This Code of Conduct applies within all community spaces, and also applies when 54 | an individual is officially representing the community in public spaces. 55 | Examples of representing our community include using an official e-mail address, 56 | posting via an official social media account, or acting as an appointed 57 | representative at an online or offline event. 58 | 59 | ## Enforcement 60 | 61 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 62 | reported to the community leaders responsible for enforcement at 63 | info@anzarkhan.com. 64 | All complaints will be reviewed and investigated promptly and fairly. 65 | 66 | All community leaders are obligated to respect the privacy and security of the 67 | reporter of any incident. 68 | 69 | ## Enforcement Guidelines 70 | 71 | Community leaders will follow these Community Impact Guidelines in determining 72 | the consequences for any action they deem in violation of this Code of Conduct: 73 | 74 | ### 1. Correction 75 | 76 | **Community Impact**: Use of inappropriate language or other behavior deemed 77 | unprofessional or unwelcome in the community. 78 | 79 | **Consequence**: A private, written warning from community leaders, providing 80 | clarity around the nature of the violation and an explanation of why the 81 | behavior was inappropriate. A public apology may be requested. 82 | 83 | ### 2. Warning 84 | 85 | **Community Impact**: A violation through a single incident or series 86 | of actions. 87 | 88 | **Consequence**: A warning with consequences for continued behavior. No 89 | interaction with the people involved, including unsolicited interaction with 90 | those enforcing the Code of Conduct, for a specified period of time. This 91 | includes avoiding interactions in community spaces as well as external channels 92 | like social media. Violating these terms may lead to a temporary or 93 | permanent ban. 94 | 95 | ### 3. Temporary Ban 96 | 97 | **Community Impact**: A serious violation of community standards, including 98 | sustained inappropriate behavior. 99 | 100 | **Consequence**: A temporary ban from any sort of interaction or public 101 | communication with the community for a specified period of time. No public or 102 | private interaction with the people involved, including unsolicited interaction 103 | with those enforcing the Code of Conduct, is allowed during this period. 104 | Violating these terms may lead to a permanent ban. 105 | 106 | ### 4. Permanent Ban 107 | 108 | **Community Impact**: Demonstrating a pattern of violation of community 109 | standards, including sustained inappropriate behavior, harassment of an 110 | individual, or aggression toward or disparagement of classes of individuals. 111 | 112 | **Consequence**: A permanent ban from any sort of public interaction within 113 | the community. 114 | 115 | ## Attribution 116 | 117 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], 118 | version 2.0, available at 119 | https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. 120 | 121 | Community Impact Guidelines were inspired by [Mozilla's code of conduct 122 | enforcement ladder](https://github.com/mozilla/diversity). 123 | 124 | [homepage]: https://www.contributor-covenant.org 125 | 126 | For answers to common questions about this code of conduct, see the FAQ at 127 | https://www.contributor-covenant.org/faq. Translations are available at 128 | https://www.contributor-covenant.org/translations. 129 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to Git Cheat Sheet 2 | 3 | Thank you for your interest in contributing to the Git Cheat Sheet! We welcome contributions from developers of all experience levels. By contributing, you’re helping make this repository more valuable for everyone. 4 | 5 | Please follow the guidelines below to ensure a smooth and consistent contribution process. 6 | 7 | ## How to Contribute 8 | 9 | ### 1. Fork the Repository 10 | Start by forking the repository to your own GitHub account. This allows you to make changes without affecting the original repository. 11 | 12 | ### 2. Clone Your Fork 13 | Clone the forked repository to your local machine: 14 | ```bash 15 | git clone https://github.com/YOUR-USERNAME/git-cheat-sheet.git 16 | ``` 17 | 18 | ### 3. Create a Branch 19 | Once you've cloned the repository, navigate to the project directory and create a new branch for your changes. It's good practice to name your branch according to the feature or bug you're working on. For example: 20 | ```bash 21 | git checkout -b feature/add-new-command 22 | ``` 23 | 24 | 25 | ### 4. Make Your Changes 26 | Once you’ve created your branch, it's time to make the changes. Here are some tasks you may want to consider: 27 | - **Add New Commands**: If you're adding a new command to the cheat sheet, make sure to provide a clear explanation of its purpose and usage. Also, include an example to illustrate its functionality. 28 | - **Update Existing Commands**: If you find outdated or incorrect commands, update them with accurate information, and provide examples of the correct usage. 29 | - **Improve Explanations**: If you feel that any part of the documentation could use more clarity or detail, feel free to expand or rephrase the explanations. 30 | - **Fix Typos or Grammar**: Proofread the document and fix any spelling or grammar mistakes to improve readability. 31 | 32 | Ensure that your changes are aligned with the overall goal of the project: creating a comprehensive and easy-to-use Git command cheat sheet. 33 | 34 | ### 5. Test Your Changes 35 | Before committing your changes, it's important to test them to ensure they work correctly. Here’s what you should do: 36 | - **Check Code Syntax**: If you’ve added any new Git commands, make sure they are syntactically correct and that the explanations are accurate. 37 | - **Test Examples Locally**: For commands that include examples, run them locally to verify that they produce the expected output. If they are outdated or no longer work, provide updated examples. 38 | - **Review Formatting**: Check the formatting to ensure consistency with the rest of the cheat sheet. Ensure that headers, bullet points, and code blocks are correctly styled and easy to follow. 39 | 40 | Testing your changes helps maintain the quality and accuracy of the cheat sheet for all users. 41 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 Anzar Khan 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Github Command Cheat Sheet 2 | 3 | A quick reference guide for common and advanced Git commands with examples and detailed explanations. 4 | 5 | --- 6 | 7 | ## Configuration 8 | 9 | | Command | Description | Example | 10 | | ---------------------------------------------------- | ------------------------------------------- | ----------------------------------------------------- | 11 | | `git config --global user.name "foo"` | Sets the global username. | `git config --global user.name "John Doe"` | 12 | | `git config --global user.email "foo@example.com"` | Sets the global email. | `git config --global user.email "john@example.com"` | 13 | | `git config --list` | Displays the list of global configurations. | `git config --list` | 14 | 15 | --- 16 | 17 | ## Branches 18 | 19 | | Command | Description | 20 | | ------------------------------ | -------------------------------------------------------------------------------------- | 21 | | `git branch foo` | Create a new branch named `foo`. Example: `git branch feature-login` | 22 | | `git branch -d foo` | Deletes a branch named `foo`. Example: `git branch -d feature-login` | 23 | | `git switch foo` | Switch to the branch `foo`. Example: `git switch main` | 24 | | `git switch -c\|--create foo` | Create and switch to a new branch `foo`. Example: `git switch -c feature-search` | 25 | | `git restore foo.js` | Undo all changes to the file `foo.js` in the working directory. | 26 | | `git checkout foo.js` | Undo all changes to the file `foo.js` (legacy command; use `git restore` instead). | 27 | | `git checkout foo` | Switch to branch `foo` (legacy command; use `git switch` instead). | 28 | | `git checkout -b foo` | Create and switch to branch `foo` (legacy command; use `git switch -c` instead). | 29 | | `git merge foo` | Merge branch `foo` into the current branch. Example: `git merge feature-update` | 30 | 31 | --- 32 | 33 | ## Pulling 34 | 35 | | Command | Description | 36 | | ----------------------------- | ---------------------------------------------------------------------------------------------------------------------------- | 37 | | `git pull --rebase --prune` | Pull the latest changes from the remote repository, rebase local changes, and remove branches that no longer exist remotely. | 38 | 39 | --- 40 | 41 | ## Staged Changes 42 | 43 | | Command | Description | 44 | | ------------------------------- | ------------------------------------------------------------------------------------------------------------------------- | 45 | | `git add file.txt` | Stage a file named `file.txt` for commit. Example: `git add index.html` | 46 | | `git add -p\|--patch file.txt` | Stage parts of the changes in a file interactively. Example:`git add -p app.js` | 47 | | `git mv file1.txt file2.txt` | Rename or move a file. Example:`git mv old-name.txt new-name.txt` | 48 | | `git rm --cached file.txt` | Remove a file from the staging area without deleting it from the working directory. Example:`git rm --cached debug.log` | 49 | | `git rm --force file.txt` | Unstage and delete a file from the working directory. Example:`git rm --force unused.js` | 50 | | `git reset HEAD` | Unstage all changes but keep them in the working directory. | 51 | | `git reset --hard HEAD` | Unstage and delete all changes in the working directory.**Use with caution** as it cannot be undone. | 52 | | `git clean -f\|--force -d` | Recursively remove untracked files and directories. Example:`git clean -fd` | 53 | | `git clean -f\|--force -d -x` | Recursively remove untracked and ignored files. Example:`git clean -fdx` | 54 | 55 | --- 56 | 57 | ## Changing Commits 58 | 59 | | Command | Description | 60 | | ------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------- | 61 | | `git reset 5720fdf` | Reset the current branch to a specific commit without modifying the working directory. | 62 | | `git reset HEAD~1` | Reset the current branch to the previous commit while keeping changes in the working directory. | 63 | | `git reset --hard 5720fdf` | Reset the current branch and working directory to a specific commit.**This will erase all uncommitted changes.** | 64 | | `git commit --amend -m "New message"` | Modify the last commit message. Example:`git commit --amend -m "Fix typo in documentation"` | 65 | | `git commit --fixup 5720fdf` | Create a commit to fix or amend the specified commit. | 66 | | `git revert 5720fdf` | Create a new commit to undo changes introduced by a specific commit. | 67 | | `git rebase --interactive [origin/main]` | Rebase the current branch interactively on top of the main branch. Example:`git rebase --interactive origin/main` | 68 | | `git rebase --interactive 5720fdf` | Rebase to a specific commit interactively. | 69 | | `git rebase --continue` | Continue the rebase process after resolving conflicts. | 70 | | `git rebase --abort` | Abort an ongoing rebase operation. | 71 | | `git cherry-pick 5720fdf` | Copy a specific commit to the current branch. | 72 | 73 | --- 74 | 75 | ## Compare 76 | 77 | | Command | Description | 78 | | ------------------------ | --------------------------------------------------------- | 79 | | `git diff` | Show changes between the working directory and the index. | 80 | | `git diff HEAD HEAD~2` | Compare the current commit with two commits back. | 81 | | `git diff main other` | Show changes between two branches. | 82 | 83 | --- 84 | 85 | ## View 86 | 87 | | Command | Description | 88 | | ---------------------------------------- | -------------------------------------------------------------------------- | 89 | | `git log` | View the commit history. Example:`git log --oneline` for a concise view. | 90 | | `git log --patch` | View commits along with their changes. | 91 | | `git log --decorate --graph --oneline` | Visualize the commit history as a graph. | 92 | | `git show HEAD` | Display details of the current commit. | 93 | | `git blame file.txt` | See who made each change to a file. | 94 | 95 | --- 96 | 97 | ## Stash 98 | 99 | | Command | Description | 100 | | --------------------------------- | -------------------------------------------------------- | 101 | | `git stash push -m "Message"` | Save uncommitted changes to the stash with a message. | 102 | | `git stash --include-untracked` | Stash all uncommitted and untracked files. | 103 | | `git stash list` | View all stashed changes. | 104 | | `git stash apply` | Apply the last stashed changes to the working directory. | 105 | | `git stash clear` | Delete all stashes. | 106 | 107 | --- 108 | 109 | ## Tags 110 | 111 | | Command | Description | 112 | | ------------------------------------------------------ | ------------------------------------------------------------------------- | 113 | | `git tag` | List all tags. | 114 | | `git tag -a\|--annotate 0.0.1 -m\|--message "Message"` | Create an annotated tag. Example:`git tag -a v1.0 -m "Initial release"` | 115 | | `git push --tags` | Push tags to a remote repository. | 116 | 117 | --- 118 | 119 | ## Remote 120 | 121 | | Command | Description | 122 | | --------------------------------- | ---------------------------------------------------------- | 123 | | `git remote -v` | View the URLs of remote repositories. | 124 | | `git remote add upstream ` | Add a new remote repository named `upstream`. | 125 | | `git push --force-with-lease` | Push changes while ensuring no conflicting remote updates. | 126 | | `git push --tags` | Push all tags to the remote repository. | 127 | 128 | --- 129 | 130 | ## Submodules 131 | 132 | | Command | Description | 133 | | ------------------------ | ----------------------------------- | 134 | | `git submodule status` | Check the status of all submodules. | 135 | 136 | **Submodule Workflow**: 137 | 138 | 1. Sync: `git submodule sync` 139 | 2. Initialize: `git submodule init` 140 | 3. Update: `git submodule update` 141 | 142 | --- 143 | 144 | ## Notes 145 | 146 | - Always commit and push frequently to avoid losing progress. 147 | - Use `git rebase` cautiously to avoid rewriting shared commit history. 148 | - Use `git stash` for temporary work, but do not rely on it as a long-term backup. 149 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Supported Versions 4 | 5 | Use this section to tell people about which versions of your project are 6 | currently being supported with security updates. 7 | 8 | | Version | Supported | 9 | | ------- | ------------------ | 10 | | 5.1.x | :white_check_mark: | 11 | | 5.0.x | :x: | 12 | | 4.0.x | :white_check_mark: | 13 | | < 4.0 | :x: | 14 | 15 | ## Reporting a Vulnerability 16 | 17 | Use this section to tell people how to report a vulnerability. 18 | 19 | Tell them where to go, how often they can expect to get an update on a 20 | reported vulnerability, what to expect if the vulnerability is accepted or 21 | declined, etc. 22 | -------------------------------------------------------------------------------- /git command.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/benzocv/git-toolbox/8f50f32c821fcf9087e14eba55262cbc9bc6b53a/git command.txt --------------------------------------------------------------------------------