top of page

Git Roadmap

  • Writer: Sairam Penjarla
    Sairam Penjarla
  • Jun 7, 2024
  • 2 min read

Most Important commands

  • Initialize a repository: git init

  • Clone a repository: git clone <repository-url>

  • Check the status of your working directory: git status

  • Add files to staging area: git add .

  • Commit changes: git commit -m "Initial commit"

  • Push changes to remote repository: git push origin main

  • Create a new branch and switch to it: git checkout -b feature-branch

  • Merge a branch into the main branch: git checkout main git merge feature-branch

  • Stash changes temporarily: git stash

  • Apply stashed changes: git stash apply


All commands

Initializing a Repository

  • git init: Initialize a new Git repository


Configuring Git

  • git config: Set up Git configurations

  • git config --global user.name "Your Name": Set your name for commits

  • git config --global user.email "your.email@example.com": Set your email for commits


Creating and Cloning Repositories

  • git clone <repository-url>: Clone a repository from a URL

  • git clone <repository-url> <directory>: Clone a repository into a specific directory

  • git clone --depth=1 <repository-url>: Clone a repository with a limited history.


Basic Repository Operations

  • git status: Check the status of the repository

  • git add <file>: Add file(s) to the staging area

  • git commit -m "Commit message": Commit staged changes with a message

  • git commit -am "Commit message": Stage and commit all modified files with a message

  • git log: View commit history


Branching and Merging

  • git branch: List all branches

  • git branch <branch-name>: Create a new branch

  • git checkout <branch-name>: Switch to a different branch

  • git merge <branch-name>: Merge changes from another branch into the current branch

  • git branch -d <branch-name>: Delete a branch


Remote Repositories

  • git remote add <name> <url>: Add a new remote repository

  • git remote -v: List all remote repositories

  • git push <remote-name> <branch-name>: Push local commits to a remote repository

  • git pull <remote-name> <branch-name>: Fetch and merge changes from a remote repository

  • git fetch <remote-name>: Fetch changes from a remote repository without merging.


Undoing Changes

  • git checkout -- <file>: Discard changes in the working directory for a specific file

  • git reset HEAD <file>: Unstage changes for a specific file

  • git reset --hard HEAD: Discard all local changes and revert to the last commit

  • git revert <commit>: Revert a specific commit


Advanced Git Techniques

  • git rebase <branch-name>: Reapply commits on top of another base

  • git cherry-pick <commit>: Apply a specific commit to the current branch

  • git tag <tag-name>: Create a lightweight tag

  • git submodule: Manage Git submodules



Git Collaboration

  • git fetch: Download objects and refs from another repository

  • git push: Update remote refs along with associated objects

  • git pull: Fetch from and integrate with another repository or a local branch

Git Workflow

  • git flow init: Initialize a repository for GitFlow

  • git flow feature start <feature-name>: Start a new feature branch

  • git flow feature finish <feature-name>: Finish a feature branch and merge it into develop

  • git flow release start <version>: Start a new release branch

  • git flow release finish <version>: Finish a release branch and merge it into master and develop

 
 

Sign up for more like this.

Thanks for submitting!

bottom of page