{"id":21151284,"url":"https://github.com/vidyasagaryadav499/git-playground","last_synced_at":"2026-05-19T00:40:24.089Z","repository":{"id":191224990,"uuid":"684142885","full_name":"VidyasagarYadav499/git-playground","owner":"VidyasagarYadav499","description":"Repo for learning about, and practicing Git \u0026 Github.","archived":false,"fork":false,"pushed_at":"2025-01-14T16:27:41.000Z","size":31,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-14T18:12:17.385Z","etag":null,"topics":["git","github","learning-by-doing"],"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/VidyasagarYadav499.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":"2023-08-28T14:43:02.000Z","updated_at":"2025-01-14T16:27:46.000Z","dependencies_parsed_at":null,"dependency_job_id":"dbf5f797-b46f-450d-832e-f5f9d9f7dea4","html_url":"https://github.com/VidyasagarYadav499/git-playground","commit_stats":null,"previous_names":["vidyasagaryadav499/hello-world"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VidyasagarYadav499%2Fgit-playground","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VidyasagarYadav499%2Fgit-playground/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VidyasagarYadav499%2Fgit-playground/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VidyasagarYadav499%2Fgit-playground/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/VidyasagarYadav499","download_url":"https://codeload.github.com/VidyasagarYadav499/git-playground/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243591182,"owners_count":20315816,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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","learning-by-doing"],"created_at":"2024-11-20T10:15:44.356Z","updated_at":"2026-05-19T00:40:24.039Z","avatar_url":"https://github.com/VidyasagarYadav499.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Table of Contents\n\n- [Hello World! 🌏](#hello-world-)\n- [Git \u0026 GitHub Workflow 📚✨🌐](#git--github-workflow-)\n- [Git Commands 📖](#git-commands-)\n- [Complete Guide to Git Merging and Rebasing 🔄](#complete-guide-to-git-merging-and-rebasing-)\n- [Interactive Rebase 🌵](#interactive-rebase-)\n- [Important Points ⚠](#important-points-)\n\n# Hello World! 🌏\n\nHi there!👋, my name is **Vidyasagar Yadav** and this is the **first repository** that i have created, to embark on a journey of learning and practicing **Git** \u0026 **Github** along with it's various functions and features.\n\n# Git \u0026 GitHub Workflow 📚✨🌐\n\n## 1. Clone the Repository 💾✨🌍\nTo start working on a project, clone the repository from GitHub to your local machine.\n\n```\ngit clone \u003crepo-url\u003e\n```\n\n## 2. Create a New Branch 🌳✨🔧\nBefore making changes, create a new branch to keep your work separate from the main branch.\n\n```\ngit checkout -b \u003cbranch-name\u003e  # Creates and switches to a new branch\ngit branch \u003cbranch-name\u003e       # Creates a new branch\ngit checkout \u003cbranch-name\u003e     # Switches to the newly created branch\n```\n\nAlternatively, you can use:\n\n```\ngit branch -c \u003cbranch-name\u003e    # Creates a new branch and copies the current branch's history\n```\n\n## 3. Work on Your Branch 📚🌿✨\nMake your changes, then stage and commit them.\n\n```\ngit add .                      # Stages all changes in the current directory\ngit commit -m \"commit message\" # Commits the staged changes with a descriptive message\n```\n\nUse these additional commands if needed:\n\n```\ngit status                     # Shows the status of the working directory\ngit diff                       # Shows the differences between the working directory and the index\n```\n\n## 4. Push Your Branch to Remote Repository 🌐📢✨\nPush your branch to the remote repository to share your changes.\n\n```\ngit push -u origin \u003cbranch-name\u003e  # Pushes the branch and sets the upstream reference\n```\n\n## 5. Create a Pull Request on GitHub 🔧📚🌟\nGo to GitHub, navigate to your repository, and create a pull request to propose your changes for review.\n\n## 6. Review and Merge 💡🌿🔄\nAfter the pull request is reviewed and approved, merge it into the main branch on GitHub.\n\n## 7. Update Your Local Repository (main branch) 🌐🔧🌿\nKeep your local main branch up-to-date with the remote repository.\n\n```\ngit switch main                # Switches to the main branch\ngit pull origin main          # Pulls the latest changes from the remote main branch\n```\n\nAlternatively, you can use:\n\n```\ngit checkout main              # Switches to the main branch\ngit fetch origin               # Fetches changes from the remote repository\ngit merge origin/main         # Merges the fetched changes into the main branch\n```\n\n# Git Commands 📖\n| Command | Description |\n|---|---|\n| **Initialization Commands** |  |\n| `git init` | Initializes a new git repository by adding a `.git` folder to it. |\n| `git clone \u003curl\u003e` | Creates a copy of an existing repository from a remote URL. Example: `git clone https://github.com/user/repo.git` |\n| **Staging Commands** |  |\n| `git add -A` | Adds all changes (tracked and untracked) to the staging area. |\n| `git add .` | Adds new/untracked files or modified files to the staging area in the current directory. |\n| `git add \u003cfile\u003e` | Adds a specific file to the staging area. Example: `git add index.html` |\n| **Commit Commands** |  |\n| `git commit -m \"message\"` | Commits changes with a message. Example: `git commit -m \"Add login feature\"` |\n| `git commit --amend` | Adds changes to the latest commit and allows editing the commit message. |\n| `git commit --amend --no-edit` | Adds changes to the latest commit without changing the commit message. |\n| `git commit -a -m \"message\"` | Commits all tracked files with a message, skipping the staging area. Example: `git commit -a -m \"Fix typos\"` |\n| **Status Commands** |  |\n| `git status` | Displays the status of the working directory and staging area. |\n| `git status -s` | Shows a short format for the status. |\n| **Push Commands** |  |\n| `git push` | Pushes changes from the local repository to the remote repository's default branch. |\n| `git push \u003cremote\u003e \u003cbranch\u003e` | Pushes the specified branch to the specified remote repository. Example: `git push origin feature/login` |\n| `git push --force` | Forces the push by overwriting the remote branch history with local history. Example: `git push --force` |\n| `git push --all \u003cremote\u003e` | Pushes all local branches to the specified remote repository. Example: `git push --all origin` |\n| `git push --tags` | Pushes all tags to the remote repository. |\n| `git push --set-upstream \u003cremote\u003e \u003cbranch\u003e` | Sets the remote branch as the upstream branch for the local branch and pushes to it. Example: `git push --set-upstream origin feature/login` |\n| **Fetch Commands** |  |\n| `git fetch` | Downloads all branches and tags from the default remote repository. |\n| `git fetch \u003cremote\u003e` | Fetches data from a specified remote repository. Example: `git fetch origin` |\n| `git fetch \u003cremote\u003e \u003cbranch\u003e` | Fetches updates from a specific branch of the remote repository. Example: `git fetch origin develop` |\n| `git fetch --all` | Fetches updates from all configured remotes. |\n| `git fetch --prune` | Removes references to branches deleted from the remote. |\n| **Pull Commands** |  |\n| `git pull` | Fetches and merges changes from the default remote and branch. |\n| `git pull \u003cremote\u003e \u003cbranch\u003e` | Pulls changes from a specific branch of the remote repository. Example: `git pull origin main` |\n| `git pull --rebase` | Fetches changes and rebases the local branch on top of the remote branch. |\n| `git pull --strategy=\u003cstrategy\u003e` | Uses a specific merge strategy when pulling changes. Example: `git pull --strategy=recursive` |\n| **Checkout Commands** |  |\n| `git checkout \u003cbranch\u003e` | Switches to the specified branch. Example: `git checkout feature-xyz` |\n| `git checkout -b \u003cname\u003e` | Creates a new branch and switches to it. Example: `git checkout -b new-feature` |\n| `git checkout \u003chash\u003e` | Checks out a specific commit, detaching the HEAD. Example: `git checkout abc1234` |\n| `git checkout \u003cfile\u003e` | Restores a specific file from the last commit or the index. Example: `git checkout README.md` |\n| **Branch Commands** |  |\n| `git branch` | Lists all local branches. |\n| `git branch -c \u003cname\u003e` | Creates a new branch with the specified name. Example: `git branch -c feature/search` |\n| `git branch -d \u003cbranch\u003e` | Deletes the specified branch. Example: `git branch -d feature/old` |\n| `git branch -m \u003coldname\u003e \u003cnewname\u003e` | Renames the specified branch. Example: `git branch -m feature/old feature/new` |\n| **Configuration Commands** |  |\n| `git config --global alias.\u003calias\u003e \"\u003ccommand\u003e\"` | Creates a global alias for a git command. Example: `git config --global alias.co \"checkout\"` |\n| `git config --global user.name \"\u003cname\u003e\"` | Sets the global username for commits. Example: `git config --global user.name \"John Doe\"` |\n| `git config --global user.email \"\u003cemail\u003e\"` | Sets the global email for commits. Example: `git config --global user.email \"john@example.com\"` |\n| **Remote Commands** |  |\n| `git remote add \u003cname\u003e \u003curl\u003e` | Adds a new remote repository. Example: `git remote add upstream https://github.com/original/repo.git` |\n| `git remote remove \u003cname\u003e` | Removes the specified remote repository. Example: `git remote remove upstream` |\n| `git remote rename \u003cold\u003e \u003cnew\u003e` | Renames a remote repository. Example: `git remote rename origin upstream` |\n| **Log Commands** |  |\n| `git log` | Shows the commit history. |\n| `git log --all --decorate --oneline --graph` | Displays a detailed log with graph view. |\n| `git log -p` | Shows the commit history with the diffs of each commit. |\n| **Reset Commands** |  |\n| `git reset HEAD \u003cfile\u003e` | Unstages a file without removing changes. Example: `git reset HEAD index.html` |\n| `git reset --hard \u003ccommit\u003e` | Resets to a specific commit, discarding all changes. Example: `git reset --hard HEAD~1` |\n| **Stash Commands** |  |\n| `git stash save \"\u003cmessage\u003e\"` | Stashes changes with a descriptive message. Example: `git stash save \"WIP: login feature\"` |\n| `git stash pop` | Applies and removes the last stashed changes. |\n| **Clean Commands** |  |\n| `git clean -df` | Removes untracked files and directories forcefully. |\n| `git clean -n` | Shows what would be removed by `git clean`. |\n| **Rebase Commands** |  |\n| `git rebase \u003cbranch\u003e` | Rebases current branch on top of specified branch. Example: `git rebase main` |\n| `git rebase \u003cremote\u003e/\u003cbranch\u003e` | Rebases on top of a remote branch. Example: `git rebase origin/main` |\n| `git rebase --onto \u003cnewbase\u003e \u003coldbase\u003e \u003cbranch\u003e` | Rebases specified branch onto new base. Example: `git rebase --onto main feature/v1 feature/v2` |\n| **Tag Commands** |  |\n| `git tag \u003ctagname\u003e` | Creates a lightweight tag at the current commit. Example: `git tag v1.0.0` |\n| `git tag -a \u003ctagname\u003e -m \"\u003cmessage\u003e\"` | Creates an annotated tag with a message. Example: `git tag -a v1.0.0 -m \"Release version 1.0.0\"` |\n| **Diff Commands** |  |\n| `git diff` | Shows unstaged changes. |\n| `git diff --staged` | Shows staged changes. |\n| `git diff \u003ccommit1\u003e \u003ccommit2\u003e` | Shows changes between two commits. Example: `git diff abc1234 def5678` |\n\n# Complete Guide to Git Merging and Rebasing 🔄\n\n## 1. Basic Git Merging 🧩\n\n### What is Merging?\nMerging is like combining different versions of your work into one final version. In Git, it's the process of integrating changes from one branch into another.\n\n### Basic Merge Commands\n```\n# Switch to target branch (e.g., main)\ngit checkout main\n\n# Merge another branch into current branch\ngit merge feature-branch\n```\n\n## 2. Handling Merge Conflicts ⚡\n\n### What a Conflict Looks Like\n```\n\u003c\u003c\u003c\u003c\u003c\u003c\u003c HEAD (Current branch)\nYour changes\n=======\nTheir changes\n\u003e\u003e\u003e\u003e\u003e\u003e\u003e feature-branch\n```\n\n### Steps to Resolve Conflicts\n1. Check conflicted files:\n```\ngit status\n```\n\n2. Edit conflicted files\n- Remove conflict markers\n- Choose desired changes\n- Save files\n\n3. Complete the merge:\n```\n# Add resolved files\ngit add fixed-file.txt\n\n# Commit the merge\ngit commit -m \"Resolved merge conflicts\"\n```\n\n## 3. Three-Way Merge 🌟\nA three-way merge occurs when Git needs to consider three different versions:\n- Common ancestor (original version)\n- Your branch changes\n- Their branch changes\n\n```\n# Automatic three-way merge\ngit checkout main\ngit merge feature-branch\n```\n\nGit automatically performs a three-way merge when needed by comparing:\n1. Last common commit between branches\n2. Latest commit on main\n3. Latest commit on feature-branch\n\n## 4. Rebasing 🔄\n\n### Basic Rebase Command\n```\n# Go to branch to rebase\ngit checkout feature-branch\n\n# Rebase onto main\ngit rebase main\n```\n\n### Complete Rebase Process\n1. Save current work:\n```\ngit add .\ngit commit -m \"Save changes\"\n```\n\n2. Update main:\n```\ngit checkout main\ngit pull\n```\n\n3. Perform rebase:\n```\ngit checkout feature-branch\ngit rebase main\n```\n\n### Handling Rebase Conflicts\n```\n# After fixing conflicts\ngit add fixed-file.txt\ngit rebase --continue\n\n# To cancel rebase\ngit rebase --abort\n```\n\n## 5. Merge vs. Rebase Comparison\n\n### Merge Structure\n```\nBefore merge:\nA---B---C (main)\n     \\\n      D---E (feature)\n      \nAfter merge:\nA---B---C---F (main)\n     \\     /\n      D---E (feature)\n```\n\n### Rebase Structure\n```\nBefore rebase:\nA---B---C (main)\n     \\\n      D---E (feature)\n      \nAfter rebase:\nA---B---C (main)\n         \\\n          D'---E' (feature)\n```\n\n## 6. When to Use What\n\n### Use Merge When:\n- Working on shared branches\n- Need to preserve exact history\n- Working on long-running features\n\n### Use Rebase When:\n- Keeping feature branch updated with main\n- Want a linear history\n- Working on personal branches\n\n## 7. Best Practices\n\n### Safety Tips 🛡️\n1. Always verify current branch before merging/rebasing\n2. Keep work backed up\n3. Seek help when uncertain\n4. Take time with conflict resolution\n\n### Golden Rules for Rebasing 👑\n1. Never rebase shared branches\n2. Rebase before pushing to remote\n3. Default to merge if unsure\n\n### Helpful Commands\n```\n# Check current branch\ngit branch\n\n# View status\ngit status\n\n# Abort merge\ngit merge --abort\n\n# Abort rebase\ngit rebase --abort\n```\n\n# Interactive Rebase 🌵\n\nInteractive Rebase is a tool for optimizing and cleaning up your commit history. It's like a swiss-army knife for git operations.\nIt can help peform various operations:\n - Change a commit's message.\n - Delete commits.\n - Reorder commits,\n - Squash: Combine multiple commits into one.\n - Edit/split an existing commit into mutliple new ones.\n\n\u003e ⚠️ **Warning:** Do NOT use Interactive Rebase on commits that you have already pushed/shared on a remote repository! Instead, use it to clean your local commit history before merging it into a shared team branch. Remember this mantra, **NEVER REBASE PUSHED COMMITS!**\n\n## Workflow 🍃༄\n### Step 1: Determine the Base Commit\n1. **How far do you want to go?**\n   - Decide which commit you want to start from, at least the ancestor or parent of the commit you want to change.\n\n2. **Choose the Base Commit**:\n   - Use `git log` or `git log --oneline` to find the appropriate commit hash or relative reference.\n   \n     ```\n     git log --oneline\n     ```\n\n### Step 2: Start the Interactive Rebase\n1. **Run the Command**:\n   - Start the interactive rebase with one of the following commands:\n\n     ```\n     git rebase --interactive HEAD~3\n     ```\n     OR\n     ```\n     git rebase -i HEAD~3\n     ```\n     OR\n     ```\n     git rebase -i \u003chash\u003e\n     ```\n\n### Step 3: Choose Actions in the Editor\n1. **Editor Opens**:\n   - A text editor will open, listing commits from the base commit to the HEAD.\n   \n2. **Determine Actions**:\n   - For each commit, specify the action to perform:\n     - `pick`: Use the commit as is (default).\n     - `reword`: Change the commit message.\n     - `edit`: Amend the commit content.\n     - `squash`: Combine this commit with the previous one, merging messages.\n     - `fixup`: Combine with the previous commit, discarding this commit's message.\n     - `drop`: Remove the commit entirely.\n\n3. **Example**:\n   ```\n   pick abc123 Commit message 1\n   reword def456 Commit message 2\n   edit ghi789 Commit message 3\n   ```\n\n4. **Save and Close**:\n   - Save the file and close the editor to proceed.\n\n### Step 4: Execute Actions\n1. **Reword Commit Messages**:\n   - If `reword` was chosen, Git will prompt you to edit the commit message. Update the message, save, and close.\n\n2. **Edit Commit Content**:\n   - If `edit` was chosen, Git will pause the rebase. Make your changes, stage them, and amend the commit:\n     \n     ```\n     git add \u003cfile\u003e\n     git commit --amend\n     ```\n   - Continue the rebase:\n     \n     ```\n     git rebase --continue\n     ```\n\n3. **Resolve Conflicts** (if any):\n   - If conflicts arise, resolve them manually, then stage the resolved files:\n     \n     ```\n     git add \u003cfile\u003e\n     ```\n   - Continue the rebase:\n     \n     ```\n     git rebase --continue\n     ```\n   - To abort the rebase if needed:\n     \n     ```\n     git rebase --abort\n     ```\n\n### Step 5: Finalize and Verify\n1. **Completion**:\n   - Once all commits are processed, the rebase completes successfully.\n     \n2. **Review History**:\n   - Check the updated commit history to ensure everything is as expected:\n     \n     ```\n     git log --oneline\n     ```\n\n## Additional Tips:\n- **Backup Branch**: Before rebasing, create a backup branch for safety:\n  \n  ```\n  git branch backup-branch\n  ```\n  \n- **Rebase Shared History**: Be cautious when rebasing commits that have been shared with others. Coordinate with your team to avoid issues.\n\n# Important Points ⚠\n\n1. Suppose you create a branch, say `my-branch` and you work on this and do not commit the changes and try to switch to some other branch, say `main` you may loose the changes you made on `my-branch`. Commit your changes before switching branches!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvidyasagaryadav499%2Fgit-playground","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvidyasagaryadav499%2Fgit-playground","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvidyasagaryadav499%2Fgit-playground/lists"}