├── CHEATSHEET.md ├── INTERVIEW.md ├── LICENSE └── README.md /CHEATSHEET.md: -------------------------------------------------------------------------------- 1 | # Git Cheatsheet: Mastering Commonly Used Commands 2 | 3 | This cheat sheet serves as a quick reference for mastering the most commonly used Git commands. Covering a wide range of topics, including Git basics, branching and merging, advanced concepts, and professional best practices, these commands are organized by category and include explanations and examples to facilitate comprehension and application. 4 | 5 | ## Common Commands: 6 | 7 | - `git clone ` - Create a local copy of a remote repository. 8 | - `git init` - Initialize a new Git repository in the current directory. 9 | - `git add ` - Stage a file for commit. 10 | - `git commit -m ""` - Commit the staged changes with a message. 11 | - `git push` - Push committed changes to a remote repository. 12 | - `git pull` - Fetch and merge changes from a remote repository. 13 | - `git branch ` - Create a new branch. 14 | - `git checkout ` - Switch to a different branch. 15 | - `git merge ` - Merge a branch into the current branch. 16 | - `git status` - Display the current state of the repository. 17 | 18 | ## Branching and Merging: 19 | 20 | - `git branch -d ` - Delete a local branch. 21 | - `git push --delete ` - Delete a remote branch. 22 | - `git cherry-pick ` - Apply changes from a specific commit to the current branch. 23 | - `git rebase ` - Reapply commits from the current branch on top of another branch. 24 | - `git cherry-pick --abort` - Abort the cherry-pick operation. 25 | - `git rebase --abort` - Abort the rebase operation. 26 | 27 | ## Stashing and Cleaning: 28 | 29 | - `git stash` - Temporarily save changes that have not been committed. 30 | - `git stash pop` - Restore changes saved with `git stash` and remove the stash. 31 | - `git stash apply` - Restore changes saved with `git stash`, leaving the stash in place. 32 | - `git stash drop` - Discard the latest stash. 33 | - `git stash list` - Display a list of stashes. 34 | - `git stash clear` - Remove all stashes. 35 | - `git stash branch ` - Create a new branch and restore changes saved with `git stash`. 36 | - `git clean ` - Remove untracked files and directories from the working tree. 37 | 38 | ## History and Diffs: 39 | 40 | - `git log` - Display a log of commits on the current branch. 41 | - `git diff` - Show changes made in uncommitted files. 42 | - `git blame ` - Show the commit and the name of the person who last modified each line of a file. 43 | - `git show ` - Display information about a specific commit. 44 | - `git bisect` - Perform a binary search through the commit history to find a specific change. 45 | - `git bisect reset` - Exit the binary search. 46 | - `git rev-list` - List commit objects in reverse chronological order. 47 | - `git rev-list --all` - List all commit objects. 48 | - `git rev-list --branches` - List commit objects reachable from any branch. 49 | - `git rev-list --remotes` - List commit objects reachable from any remote branch. 50 | - `git rev-list --tags` - List commit objects reachable from any tag. 51 | - `git rev-list --stdin` - Read commit objects from standard input. 52 | - `git rev-list --quiet` - Suppress the default output of `git rev-list`. 53 | 54 | ## Remote Repositories: 55 | 56 | - `git fetch` - Download objects and references from a remote repository. 57 | - `git fetch --all` - Fetch updates from all remote repositories. 58 | - `git fetch --prune` - Prune local branches deleted on the remote. 59 | - `git push` - Push committed changes to a remote repository. 60 | - `git push --tags` - Push all tags to the remote repository. 61 | - `git ls-remote` - Display references in a remote repository. 62 | - `git remote prune ` - Remove local branches deleted on the remote. 63 | - `git remote add ` - Add a new remote repository. 64 | - `git remote set-url ` - Set the URL for a remote repository. 65 | - `git remote rename ` - Rename a remote repository. 66 | - `git remote show ` - Display information about a remote repository. 67 | - `git remote` - List remote repositories for the current repository. 68 | 69 | ## Tags: 70 | 71 | - `git tag ` - Add a tag to the current commit. 72 | - `git tag -d ` - Delete a local tag. 73 | - `git push --delete ` - Delete a remote tag. 74 | 75 | ## Miscellaneous: 76 | 77 | - `git log --oneline` - Display a condensed summary of the commit history. 78 | - `git log --decorate` - Display references in the commit log. 79 | - `git log --graph` - Display a graphical representation of the commit history. 80 | - `git log --follow ` - Display the commit history for a file, including renames. 81 | - `git shortlog` - Display a summary of commits by author. 82 | - `git describe ` - Display a human-readable description of a commit. 83 | - `git reset ` - Remove a file from the staging area. 84 | - `git mv ` - Rename a file. 85 | - `git rm ` - Remove a file from the repository and the filesystem. 86 | - `git show-ref` - List references in the local repository. 87 | - `git for-each-ref` - Perform an action on each reference. 88 | - `git symbolic-ref ` - Create a symbolic reference. 89 | - `git symbolic-ref --short ` - Expand a symbolic reference to its shorthand name. 90 | - `git for-each-ref --format ` - Customize the output of `git for-each-ref`. 91 | -------------------------------------------------------------------------------- /INTERVIEW.md: -------------------------------------------------------------------------------- 1 | # Git Interview: Commonly Asked Questions 2 | 3 | Welcome to the Git Interview, a comprehensive collection of commonly asked Git interview questions. Whether you're preparing for an interview or looking to deepen your understanding of Git, this resource covers a broad spectrum of topics, from fundamental concepts to advanced techniques and best practices. 4 | 5 | ## Git Basics 6 | 1. **What is Git, and why is it useful?** 7 | 2. **How do you create a new Git repository?** 8 | 3. **How do you clone an existing Git repository?** 9 | 4. **How do you stage and commit changes in Git?** 10 | 5. **How do you push and pull changes from a remote repository?** 11 | 12 | ## Branching and Merging 13 | 1. **How do you create a new branch in Git?** 14 | 2. **How do you switch between branches in Git?** 15 | 3. **How do you delete a branch in Git?** 16 | 4. **How do you merge branches in Git?** 17 | 5. **What are some strategies for resolving conflicts in Git?** 18 | 19 | ## Advanced Git Concepts 20 | 1. **What is rebasing in Git, and when would you use it?** 21 | 2. **What is cherry-picking in Git, and when would you use it?** 22 | 3. **What is bisecting in Git, and when would you use it?** 23 | 4. **Can you explain Git's data model and internals?** 24 | 5. **How do you optimize your Git workflow?** 25 | 26 | ## Git in a Professional Setting 27 | 1. **What are some best practices for using Git in a team environment?** 28 | 2. **How do you use branching and merging to manage code changes in a team setting?** 29 | 3. **How do you use Git with continuous integration and deployment tools?** 30 | 4. **Can you explain the difference between a centralized and a decentralized version control system?** 31 | 5. **How do you handle large projects with Git?** 32 | 33 | Each question is designed to deepen your understanding of Git concepts and prepare you for technical discussions in interviews. Understanding these topics will not only help you excel in interviews but also in real-world scenarios where Git is an integral part of collaborative software development. 34 | 35 | Feel free to dive into each question, explore further, and master the Git ecosystem. Happy interviewing! 36 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Sugeng Agung Suganda 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 | # Git Course: Cheatsheet and Interview Questions 2 | 3 | Welcome to the Git Course repository! This repository serves as a comprehensive resource for mastering Git concepts, featuring a Git cheat sheet and a curated list of interview questions. 4 | 5 | ## Contents: 6 | 7 | - [Git Cheatsheet](CHEATSHEET.md): A quick reference for the most commonly used Git commands. Covering Git basics, branching, merging, advanced concepts, and professional best practices, each command is explained with examples for better understanding. 8 | 9 | - [Git Interview](INTERVIEW.md): A comprehensive guide to preparing for technical interviews focusing on Git. Organized by category and ordered by popularity, these questions cover a wide range of topics, from fundamental commands to advanced concepts and professional best practices. 10 | 11 | We encourage you to explore these resources, contribute to improvements, and share your feedback. If you have any questions or suggestions, feel free to open an issue or pull request in this repository. 12 | 13 | Thank you for visiting! 14 | --------------------------------------------------------------------------------