{"id":24664486,"url":"https://github.com/shihabshahrier/git-github-command-cheat-sheet","last_synced_at":"2026-05-15T23:36:48.716Z","repository":{"id":271002882,"uuid":"912123936","full_name":"shihabshahrier/Git-GitHub-Command-Cheat-Sheet","owner":"shihabshahrier","description":"Git is your version control best friend, and GitHub is where collaboration magic happens! Below is a guide to the most useful Git \u0026 GitHub commands you’ll use daily. Let’s master the flow of commits, branches, and merges! 🚀","archived":false,"fork":false,"pushed_at":"2025-01-04T17:13:19.000Z","size":5,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-21T09:47:47.215Z","etag":null,"topics":["git","github","github-branches","github-config","merge-branch"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shihabshahrier.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-04T17:07:19.000Z","updated_at":"2025-01-04T17:15:47.000Z","dependencies_parsed_at":"2025-01-04T18:23:34.532Z","dependency_job_id":"762108c8-baf4-4da7-a9b3-cd4740285f0d","html_url":"https://github.com/shihabshahrier/Git-GitHub-Command-Cheat-Sheet","commit_stats":null,"previous_names":["shihabshahrier/git-github-command-cheat-sheet"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/shihabshahrier/Git-GitHub-Command-Cheat-Sheet","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shihabshahrier%2FGit-GitHub-Command-Cheat-Sheet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shihabshahrier%2FGit-GitHub-Command-Cheat-Sheet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shihabshahrier%2FGit-GitHub-Command-Cheat-Sheet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shihabshahrier%2FGit-GitHub-Command-Cheat-Sheet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shihabshahrier","download_url":"https://codeload.github.com/shihabshahrier/Git-GitHub-Command-Cheat-Sheet/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shihabshahrier%2FGit-GitHub-Command-Cheat-Sheet/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33083661,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-15T20:25:35.270Z","status":"ssl_error","status_checked_at":"2026-05-15T20:25:34.732Z","response_time":103,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["git","github","github-branches","github-config","merge-branch"],"created_at":"2025-01-26T06:13:19.976Z","updated_at":"2026-05-15T23:36:48.697Z","avatar_url":"https://github.com/shihabshahrier.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🐙 **Git \u0026 GitHub Command Cheat Sheet**\n\nMaster Git and GitHub with this comprehensive cheat sheet. From basics to advanced tricks, this guide has everything you need to manage and collaborate on code like a pro! 🚀  \n\n---\n\n## 🌟 **Getting Started with Git**\n\n### 1. **Check Git Status**  \n   ```bash\n   git status\n   ```\n   *🛑 View modified, untracked, or staged files in your working directory.*\n\n### 2. **Initialize a Git Repository**  \n   ```bash\n   git init\n   ```\n   *📂 Turn a project directory into a Git-tracked repository.*\n\n### 3. **Clone a GitHub Repository**  \n   ```bash\n   git clone \u003crepository_url\u003e\n   ```\n   *📥 Copy a remote repository to your local machine.*\n\n---\n\n## 📤 **Making Changes Locally**\n\n### 4. **Add Files to Staging Area**  \n   ```bash\n   git add \u003cfile_name\u003e  # Add a specific file\n   git add .            # Add everything\n   ```\n   *📂 Prepare changes for commit.*\n\n### 5. **Commit Changes**  \n   ```bash\n   git commit -m \"Your message\"\n   ```\n   *💾 Save staged changes with a descriptive message.*\n\n### 6. **Unstage Files**  \n   ```bash\n   git reset \u003cfile_name\u003e\n   ```\n   *🚧 Remove files from staging without discarding changes.*\n\n---\n\n## 🌳 **Branching \u0026 Merging**\n\n### 7. **Create and Switch to a Branch**  \n   ```bash\n   git checkout -b \u003cbranch_name\u003e\n   ```\n   *🌿 Create and move to a new branch in one step.*\n\n### 8. **Merge a Branch**  \n   ```bash\n   git merge \u003cbranch_name\u003e\n   ```\n   *🔀 Combine changes from another branch into your current branch.*\n\n### 9. **Delete a Branch**  \n   ```bash\n   git branch -d \u003cbranch_name\u003e\n   ```\n   *🗑️ Remove a branch you no longer need.*\n\n---\n\n## 🌐 **Syncing with GitHub**\n\n### 10. **Push Changes**  \n   ```bash\n   git push origin \u003cbranch_name\u003e\n   ```\n   *🌐 Upload your local branch to the remote repository.*\n\n### 11. **Pull Updates**  \n   ```bash\n   git pull origin \u003cbranch_name\u003e\n   ```\n   *📥 Fetch and merge changes from the remote branch.*\n\n---\n\n## 🔧 **Advanced Git Commands**\n\n### 12. **Rebase a Branch**  \n   ```bash\n   git rebase \u003cbranch_name\u003e\n   ```\n   *🪄 Move your branch to start from the latest changes in another branch.*\n\n   **Example Workflow:**  \n   1. Switch to the feature branch: `git checkout feature-branch`  \n   2. Rebase onto main: `git rebase main`\n\n   *✨ This creates a cleaner commit history by replaying your commits on top of the target branch.*\n\n---\n\n### 13. **Squash Commits**  \n   ```bash\n   git rebase -i HEAD~\u003cnumber_of_commits\u003e\n   ```\n   *📦 Combine multiple commits into one to simplify history.*\n\n   **Example Workflow:**  \n   1. Use `git rebase -i HEAD~3` to squash the last 3 commits.  \n   2. Mark commits as `squash` or `s` in the interactive editor.  \n   3. Save and exit to merge the commits.\n\n---\n\n### 14. **Cherry-Pick a Commit**  \n   ```bash\n   git cherry-pick \u003ccommit_hash\u003e\n   ```\n   *🍒 Apply a specific commit from one branch to another.*  \n\n   **Example Workflow:**  \n   1. Find the commit hash using `git log`.  \n   2. Apply it to your branch: `git cherry-pick abc1234`.\n\n---\n\n### 15. **Stash Changes Temporarily**  \n   ```bash\n   git stash\n   ```\n   *🧳 Save your changes for later without committing.*\n\n   **Retrieve Stashed Changes:**  \n   ```bash\n   git stash pop\n   ```\n   *🪄 Apply and remove the latest stash.*\n\n---\n\n### 16. **Amend the Last Commit**  \n   ```bash\n   git commit --amend -m \"Updated commit message\"\n   ```\n   *✏️ Edit the last commit message or add files you forgot to include.*\n\n---\n\n## 🔍 **Tracking and Troubleshooting**\n\n### 17. **View Commit History**  \n   ```bash\n   git log\n   git log --oneline\n   ```\n   *📜 View detailed or one-line commit history.*\n\n### 18. **Check File Changes**  \n   ```bash\n   git diff \u003cfile_name\u003e\n   ```\n   *🔍 Compare changes in a specific file.*\n\n### 19. **Find the Commit That Introduced a Bug**  \n   ```bash\n   git bisect start\n   git bisect bad\n   git bisect good \u003ccommit_hash\u003e\n   ```\n   *🐞 Automates binary search to pinpoint the bad commit.*\n\n---\n\n## ⚙️ **Customizing Git**\n\n### 20. **Set Global User Info**  \n   ```bash\n   git config --global user.name \"Your Name\"\n   git config --global user.email \"you@example.com\"\n   ```\n   *📇 Identify yourself for all repositories.*\n\n### 21. **Alias Common Commands**  \n   ```bash\n   git config --global alias.co checkout\n   git config --global alias.br branch\n   git config --global alias.st status\n   ```\n   *⚡ Create shortcuts for frequent commands.*\n\n---\n\n## 🎉 **Bonus Tips**\n\n- **Clean Up Old Branches Locally and Remotely**  \n   ```bash\n   git branch -d \u003cbranch_name\u003e      # Delete local branch\n   git push origin --delete \u003cbranch_name\u003e  # Delete remote branch\n   ```\n\n- **Force Pull (Override Local Changes)**  \n   ```bash\n   git fetch origin\n   git reset --hard origin/\u003cbranch_name\u003e\n   ```\n   *⚠️ Warning: This overwrites your local changes.*\n\n- **Track a Remote Branch Locally**  \n   ```bash\n   git checkout --track origin/\u003cbranch_name\u003e\n   ```\n   *👣 Follows a remote branch for easy pulls and pushes.*\n\n---\n\n## 🚀 **Mastering Git Workflow**\n\n1. Create a branch for new features:  \n   ```bash\n   git checkout -b feature/new-feature\n   ```\n\n2. Commit your work:  \n   ```bash\n   git add .\n   git commit -m \"Add new feature\"\n   ```\n\n3. Push to GitHub:  \n   ```bash\n   git push origin feature/new-feature\n   ```\n\n4. Open a pull request on GitHub to merge into `main` or `develop`.\n\n---\n\n## ✨ **That's a Wrap!**\n\nYou’re now equipped with beginner and advanced Git skills. Start applying them to your projects, squash your bugs, and keep your commit history neat and clean. 🐙✨  \n\nGot feedback or more advanced topics you'd like to cover? Let me know! 😊  \n\n--- ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshihabshahrier%2Fgit-github-command-cheat-sheet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshihabshahrier%2Fgit-github-command-cheat-sheet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshihabshahrier%2Fgit-github-command-cheat-sheet/lists"}