# Git

<span class="break-words
      "><span dir="ltr">[![git.jpeg](https://resources.planforfailure.com/uploads/images/gallery/2025-03/scaled-1680-/UMKYROHHYkGsTdSk-git.jpeg)](https://resources.planforfailure.com/uploads/images/gallery/2025-03/UMKYROHHYkGsTdSk-git.jpeg)</span></span>

1. <span class="break-words
          "><span dir="ltr"> [Git commands](https://planforfailure.com/docs/gif/git_commands.gif)</span></span>
2. <span class="break-words
          "><span dir="ltr">𝐑𝐞𝐩𝐨𝐬𝐢𝐭𝐨𝐫𝐲 𝐁𝐚𝐬𝐢𝐜𝐬:  
    - Clone a Repository:  
    Command:  
    git clone &lt;repository\_url&gt;  
      
    - Initialize a Repository:  
    Command:  
    git init  
      
      
    2. 𝐖𝐨𝐫𝐤𝐢𝐧𝐠 𝐰𝐢𝐭𝐡 𝐁𝐫𝐚𝐧𝐜𝐡𝐞𝐬:  
    - Create a New Branch:  
    Command:  
    git branch &lt;branch\_name&gt;  
      
    - Switch to a Branch:  
    Command:  
    git checkout &lt;branch\_name&gt;  
      
    - Create and Switch to a New Branch:  
    Command:  
    git checkout -b &lt;new\_branch\_name&gt;  
      
    - List Branches:  
    Command:  
    git branch  
      
      
    3. 𝐂𝐨𝐦𝐦𝐢𝐭𝐭𝐢𝐧𝐠 𝐂𝐡𝐚𝐧𝐠𝐞𝐬:  
    - Stage Changes:  
    Command:  
    git add &lt;file\_name&gt;  
      
    - Stage All Changes:  
    Command:  
    git add .  
      
    - Commit Changes:  
    Command:  
    git commit -m "Commit message"  
      
      
    4. 𝐏𝐮𝐥𝐥𝐢𝐧𝐠 𝐚𝐧𝐝 𝐏𝐮𝐬𝐡𝐢𝐧𝐠:  
    - Pull Changes from Remote:  
    Command:  
    git pull origin &lt;branch\_name&gt;  
      
    - Push Changes to Remote:  
    Command:  
    git push origin &lt;branch\_name&gt;  
      
      
    5. 𝐌𝐞𝐫𝐠𝐢𝐧𝐠 𝐂𝐡𝐚𝐧𝐠𝐞𝐬:  
    - Merge Branch into Current Branch:  
    Command:  
    git merge &lt;branch\_name&gt;  
      
      
    6. 𝐖𝐨𝐫𝐤𝐢𝐧𝐠 𝐰𝐢𝐭𝐡 𝐑𝐞𝐦𝐨𝐭𝐞𝐬:  
    - Add a Remote Repository:  
    Command:  
    git remote add &lt;remote\_name&gt; &lt;repository\_url&gt;  
      
    - List Remote Repositories:  
    Command:  
    git remote -v  
      
      
    7. 𝐇𝐚𝐧𝐝𝐥𝐢𝐧𝐠 𝐂𝐨𝐧𝐟𝐥𝐢𝐜𝐭𝐬:  
    - Check for Conflicts:  
    Command:  
    git diff  
      
    - Resolve Conflicts and Continue Merge:  
    Command:  
    git add &lt;file\_name&gt;  
    git merge --continue  
      
      
    8. 𝐆𝐢𝐭𝐇𝐮𝐛 𝐀𝐜𝐭𝐢𝐨𝐧𝐬:  
    - Workflow Syntax Checking:  
    Command:  
    git pull origin &lt;branch\_name&gt;  
    git push origin &lt;branch\_name&gt;  
      
    9. 𝐌𝐢𝐬𝐜𝐞𝐥𝐥𝐚𝐧𝐞𝐨𝐮𝐬:  
    - Check Git Status:  
    Command:  
    git status  
      
    - View Commit History:  
    Command:  
    git log  
      
    - Ignore Files (Add to `.gitignore`):  
    Command:  
    echo "&lt;file\_name&gt;" &gt;&gt; .gitignore  
      
    𝓒𝓸𝓶𝓶𝓾𝓷𝓲𝓽𝔂 𝓯𝓸𝓻 𝓹𝓻𝓸𝓯𝓮𝓼𝓼𝓲𝓸𝓷𝓪𝓵𝓼 : [https://www.thealpha.dev/](https://www.thealpha.dev/)  
    </span></span>

<span class="break-words
      "><span dir="ltr">1.Core:  
• git init  
• git clone  
• git add  
• git commit  
• git status  
• git diff  
• git checkout  
• git reset  
• git log  
• git show  
• git tag  
• git push  
• git pull  
  
2.Branching:  
• git branch  
• git checkout -b  
• git merge  
• git rebase  
• git branch --set-upstream-to  
• git branch --unset-upstream  
• git cherry-pick  
  
3.Merging:  
• git merge  
• git rebase  
  
4.Stashing:  
• git stash  
• git stash pop  
• git stash list  
• git stash apply  
• git stash drop  
  
5.Remotes:  
• git remote  
• git remote add  
• git remote remove  
• git fetch  
• git pull  
• git push  
• git clone --mirror  
  
6.Configuration:  
• git config  
• git global config  
• git reset config  
  
7\. Plumbing:  
• git cat-file  
• git checkout-index  
• git commit-tree  
• git diff-tree  
• git for-each-ref  
• git hash-object  
• git ls-files  
• git ls-remote  
• git merge-tree  
• git read-tree  
• git rev-parse  
• git show-branch  
• git show-ref  
• git symbolic-ref  
• git tag --list  
• git update-ref  
  
8.Porcelain:  
• git blame  
• git bisect  
• git checkout  
• git commit  
• git diff  
• git fetch  
• git grep  
• git log  
• git merge  
• git push  
• git rebase  
• git reset  
• git show  
• git tag  
  
9.Alias:  
• git config --global alias.&lt;alias&gt; &lt;command&gt;  
  
10.Hook:  
• git config --local core.hooksPath &lt;path&gt;  
  
11.Experimental: (May not be fully Supported)  
• git annex  
• git am  
• git cherry-pick --upstream  
• git describe  
• git format-patch  
• git fsck  
• git gc  
• git help  
• git log --merges  
• git log --oneline  
• git log --pretty=  
• git log --short-commit  
• git log --stat  
• git log --topo-order  
• git merge-ours  
• git merge-recursive  
• git merge-subtree  
• git mergetool  
• git mktag  
• git mv  
• git patch-id  
• git p4  
• git prune  
• git pull --rebase  
• git push --mirror  
• git push --tags  
• git reflog  
• git replace  
• git reset --hard  
• git reset --mixed  
• git revert  
• git rm  
• git show-branch  
• git show-ref  
• git show-ref --heads  
• git show-ref --tags  
• git stash save  
• git subtree  
• git tag --delete  
• git tag --force  
• git tag --sign  
• git tag -f  
• git tag -l  
• git tag --verify  
• git unpack-file  
• git update-index  
• git verify-pack  
• git worktree  
  
\------------------- END ------------------  
  
Some good resources to Learn Git faster ☺️  
  
1.Git Official Documentation:  
[https://git-scm.com/doc](https://git-scm.com/doc)  
2.GitHub Learning Lab:  
[https://rb.gy/ksc45f](https://rb.gy/ksc45f)  
3.Codecademy Course  
[https://lnkd.in/g-87iUdn](https://lnkd.in/g-87iUdn)  
4\. Pro Git: by Scott Chacon \[Book\]  
[https://lnkd.in/gecriC8P](https://lnkd.in/gecriC8P)  
5\. YouTube  
• FreeCodeCampOrg- beginer  
[https://rb.gy/ljxt5s](https://rb.gy/ljxt5s)  
• FreeCodeCampOrg- Intermediate  
[https://rb.gy/1x6mc](https://rb.gy/1x6mc)  
• Programming with mosh  
[https://rb.gy/vfkom](https://rb.gy/vfkom)  
</span></span>