Git full — Zero to Hero

Always learning
4 min readDec 29, 2023

--

Git allows a team of people to work together, all using the same files. And it helps the team cope with the confusion that tends to happen when multiple people are editing the same files.

buymeacoffee ☕ 👈 Click the link

Git Workflows

Git flow is a lightweight, branch-based workflow that is designed to help developers collaborate on projects while also keeping their codebase organized and easy to maintain. It’s a branching strategy that was popularized by GitHub, and it’s especially well-suited for smaller teams and projects.

𝗴𝗶𝘁 𝗰𝗼𝗻𝗳𝗶𝗴 — 𝗴𝗹𝗼𝗯𝗮𝗹 𝘂𝘀𝗲𝗿.𝗻𝗮𝗺𝗲 “[𝗳𝗶𝗿𝘀𝘁𝗻𝗮𝗺𝗲 𝗹𝗮𝘀𝘁𝗻𝗮𝗺𝗲]” → Set a name that is identifiable for credit when review version history.

𝗴𝗶𝘁 𝗰𝗼𝗻𝗳𝗶𝗴 — 𝗴𝗹𝗼𝗯𝗮𝗹 𝘂𝘀𝗲𝗿.𝗲𝗺𝗮𝗶𝗹 “[𝘃𝗮𝗹𝗶𝗱-𝗲𝗺𝗮𝗶𝗹]” → Set an email address that will be associated with each history marker.

Simple terms of Git 👉 Click the link 👈

𝗴𝗶𝘁 𝘀𝘂𝗯𝗺𝗼𝗱𝘂𝗹𝗲 𝗮𝗱𝗱 𝘂𝗿𝗹_𝗴𝗶𝘁_𝗿𝗲𝗽𝗼𝘀𝗶𝘁𝗼𝗿𝘆 → Submodules allow you to keep a Git repository as a subdirectory of another Git repository.

𝗴𝗶𝘁 𝗶𝗻𝗶𝘁 → Starting a new project. It initializes a new Git repository in your current directory.

𝗴𝗶𝘁 𝗰𝗹𝗼𝗻𝗲 𝗿𝗲𝗽𝗼_𝘂𝗿𝗹 → Clone public repository.

𝗴𝗶𝘁 𝘀𝘁𝗮𝘁𝘂𝘀 → Check which files are staged and which files are modified and unstaged.

Short status flags are:

  • ?? — Untracked files
  • A — Files added to stage
  • M — Modified files
  • D — Deleted files

𝗴𝗶𝘁 𝗯𝗹𝗮𝗺𝗲 → Annotating a file with the info of who committed which line and when, one could easily discover who was to “blame” for introducing a bug.

𝗴𝗶𝘁 𝗱𝗶𝗳𝗳 → Helps you see, compare, and understand changes in your project.

𝗴𝗶𝘁 𝘀𝗵𝗼𝘄 → Used to view expanded details on Git objects such as blobs, trees, tags, and commits.

𝗴𝗶𝘁 𝗮𝗱𝗱 <𝗳𝗶𝗹𝗲𝗻𝗮𝗺𝗲> → After you’ve made some changes to your files, you’ll want to stage them for a commit. This command adds a specific file to the stage.

𝗴𝗶𝘁 𝗮𝗱𝗱 . (𝗼𝗿) 𝗴𝗶𝘁 𝗮𝗱𝗱 -𝗔 → Instead of adding files one by one, you can add all your changed files to the stage with one command.

𝗴𝗶𝘁 𝗰𝗼𝗺𝗺𝗶𝘁 -𝗺 “𝗖𝗼𝗺𝗺𝗶𝘁 𝗺𝗲𝘀𝘀𝗮𝗴𝗲” → Now that your changes are staged, you can commit them with a descriptive message.

𝗴𝗶𝘁 𝗰𝗼𝗺𝗺𝗶𝘁 — 𝗮𝗺𝗲𝗻𝗱 → Modify the most recent commit in a Git repository.

𝗴𝗶𝘁 𝗹𝗼𝗴 → See the history of all branches/tags/etc…,

𝗴𝗶𝘁 𝘁𝗮𝗴 → Similar to a Git reference, but the Git commit that it points to never changes.

𝗴𝗶𝘁 𝗽𝘂𝘀𝗵 → Upload local repository content to a remote repository

𝗴𝗶𝘁 𝗽𝘂𝗹𝗹 → Fetch and download content from a remote repository and immediately update the local repository to match that content.

𝗴𝗶𝘁 𝗽𝘂𝗹𝗹 𝗮𝗻𝗱 𝗳𝗲𝘁𝗰𝗵 → Both used to download remote content.

𝗴𝗶𝘁 𝗺𝗲𝗿𝗴𝗲 → Integrates the independent lines of development into a single branch.

𝗴𝗶𝘁 𝘀𝘁𝗮𝘀𝗵 → Used to temporarily save changes that are not yet ready to be committed. This is useful when you need to switch to a different branch

𝗴𝗶𝘁 𝗿𝗲𝗺𝗼𝘁𝗲 → Is a repository that contains the same project as you are working on in your local one, but at a different location.

𝗴𝗶𝘁 𝗽𝗮𝘁𝗰𝗵 → Text files that contain code and Git commit metadata.

𝗴𝗶𝘁 𝗿𝗲𝗯𝗮𝘀𝗲 → Rebase compresses all the changes into a single “patch.” Then it integrates the patch onto the target branch.

𝗴𝗶𝘁 𝗿𝗲𝗯𝗮𝘀𝗲 <𝗯𝗿𝗮𝗻𝗰𝗵𝗻𝗮𝗺𝗲> → Integrates changes from one branch into another.

𝗴𝗶𝘁 𝗰𝗹𝗼𝗻𝗲 → Create a copy of an existing repository. It downloads the entire repository from a remote source.

𝗴𝗶𝘁 𝗮𝗹𝗶𝗮𝘀 → Create shortcuts to frequently used Git commands.

𝗴𝗶𝘁 𝘀𝗵𝗼𝘄 𝗰𝗼𝗺𝗺𝗶𝘁-𝗶𝗱 → Replace commit-id with the id of the commit that you find in the commit log after the word commit.

𝗴𝗶𝘁 𝗿𝗺 -𝗿 [𝗳𝗶𝗹𝗲-𝗻𝗮𝗺𝗲.𝘁𝘅𝘁] → Remove a file (or) folder.

𝗴𝗶𝘁 𝗯𝗿𝗮𝗻𝗰𝗵 → List of branches (the asterisk denotes the current branch).

𝗴𝗶𝘁 𝗯𝗿𝗮𝗻𝗰𝗵 -𝗮 → List all branches (local and remote).

𝗴𝗶𝘁 𝗯𝗿𝗮𝗻𝗰𝗵 <𝗯𝗿𝗮𝗻𝗰𝗵_𝗻𝗮𝗺𝗲> : Creates a new branch.

𝗴𝗶𝘁 𝗯𝗿𝗮𝗻𝗰𝗵 -𝗱 <𝗯𝗿𝗮𝗻𝗰𝗵_𝗻𝗮𝗺𝗲> → Delete a branch.

𝗴𝗶𝘁 𝗯𝗿𝗮𝗻𝗰𝗵 -𝗗 [𝗯𝗿𝗮𝗻𝗰𝗵_𝗻𝗮𝗺𝗲] → Delete a branch forcefully.

𝗴𝗶𝘁 𝗿𝗲𝘀𝗲𝘁 [𝗳𝗶𝗹𝗲] → Undo commits and changes in the working directory.

𝗴𝗶𝘁 𝗰𝗵𝗲𝗰𝗸𝗼𝘂𝘁 <𝗯𝗿𝗮𝗻𝗰𝗵_𝗻𝗮𝗺𝗲> → Switch to a branch.

𝗴𝗶𝘁 𝗰𝗵𝗲𝗰𝗸𝗼𝘂𝘁 -𝗯 [𝗯𝗿𝗮𝗻𝗰𝗵 𝗻𝗮𝗺𝗲] → Create a new branch and switch to it.

𝗴𝗶𝘁 𝗰𝗵𝗲𝗰𝗸𝗼𝘂𝘁 -𝗯 [𝗯𝗿𝗮𝗻𝗰𝗵 𝗻𝗮𝗺𝗲] 𝗼𝗿𝗶𝗴𝗶𝗻/[𝗯𝗿𝗮𝗻𝗰𝗵 𝗻𝗮𝗺𝗲] → Clone a remote branch and switch to it.

𝗴𝗶𝘁 𝗿𝗲𝘃𝗲𝗿𝘁 <𝗯𝗿𝗮𝗻𝗰𝗵𝗻𝗮𝗺𝗲> → Undoes a commit by creating a new commit.

𝗴𝗶𝘁 𝗺𝗲𝗿𝗴𝗲 <𝗯𝗿𝗮𝗻𝗰𝗵𝗻𝗮𝗺𝗲> → Merge a branch into the active branch.

𝗴𝗶𝘁 𝗺𝗲𝗿𝗴𝗲 [𝘀𝗼𝘂𝗿𝗰𝗲 𝗯𝗿𝗮𝗻𝗰𝗵] [𝘁𝗮𝗿𝗴𝗲𝘁 𝗯𝗿𝗮𝗻𝗰𝗵] → Merge a branch into a target branch.

𝗴𝗶𝘁 𝗳𝗲𝘁𝗰𝗵 <𝗿𝗲𝗺𝗼𝘁𝗲 𝗯𝗿𝗮𝗻𝗰𝗵𝗻𝗮𝗺𝗲> → Downloads commits, files, and refs from a remote repository into a local repo.

𝗴𝗶𝘁 𝗮𝗺 → Used to import commits from email patches.

𝗴𝗶𝘁 𝗽𝘂𝗹𝗹 <𝗿𝗲𝗺𝗼𝘁𝗲 𝗯𝗿𝗮𝗻𝗰𝗵𝗻𝗮𝗺𝗲> → Update a local repository from the corresponding remote repository.

𝗴𝗶𝘁 𝗽𝘂𝘀𝗵 <𝗿𝗲𝗺𝗼𝘁𝗲 𝗯𝗿𝗮𝗻𝗰𝗵𝗻𝗮𝗺𝗲> → Transfer commits from your local repository to a remote repo.

𝗴𝗶𝘁 𝗽𝘂𝘀𝗵 𝗼𝗿𝗶𝗴𝗶𝗻 — 𝗱𝗲𝗹𝗲𝘁𝗲 [𝗯𝗿𝗮𝗻𝗰𝗵 𝗻𝗮𝗺𝗲] → Delete a remote branch.

𝗴𝗶𝘁 𝗳𝗼𝗿𝗸 → Another way of saying clone or copy.

𝗴𝗶𝘁 𝗰𝗵𝗲𝗿𝗿𝘆𝗽𝗶𝗰𝗸 → Apply specific changes before you are ready to create or merge a pull request.

𝗴𝗶𝘁 𝗴𝗰 — 𝗽𝗿𝘂𝗻𝗲=𝗻𝗼𝘄 — 𝗮𝗴𝗴𝗿𝗲𝘀𝘀𝗶𝘃𝗲 → Remove an accidentally added big file from repo. [GC → Garbage Collection]

𝗴𝗶𝘁 𝗯𝗶𝘀𝗲𝗰𝘁 → Performs a binary search to find the faulty commit.

--

--

Always learning

கற்றுக் கொள்ளும் மாணவன்...