Skip to content

Git

Repository Setup

  • git init: Initialize a new Git repository
  • git clone [url]: Clone a repository into a new directory

Staging & Committing

  • git add [file]: Add a file to the staging area
  • git add .: Add all new and changed files to the staging area
  • git commit -m "[message]": Commit the staged changes with a message
  • git commit -am "[message]": Stage all tracked files and commit

Branching & Merging

  • git branch: List all local branches
  • git branch [name]: Create a new branch
  • git checkout [name]: Switch to a branch
  • git merge [branch]: Merge a branch into the current branch

Remote Repositories

  • git remote -v: List all remote repositories
  • git pull: Fetch and merge changes from the remote
  • git push: Push local changes to the remote

History & Status

  • git status: Show the working tree status
  • git log: Show the commit history