Git Basic Commands Cheat Sheet
Initialize a Git repository
git init # Create a new Git repository in the current folderAdd files to staging area
git add . # Add all modified and new files
git add filename # Add a specific fileCommit changes
git commit -m "Your commit message" # Save staged changes with a messageCheck the status of your working directory
git status # See which files are modified, staged, or untrackedView commit history
git log # Show a list of past commitsPush to remote repository
git push origin main # Push local main branch to remote
git push origin master # Push local master branch to remoteClone a remote repository
git clone https://github.com/your-username/your-repo.git # Copy remote repo to localPull the latest changes from remote
git pull # Fetch and merge changes from the remote branchSet the remote repository (only needed once)
git remote add origin https://github.com/your-username/your-repo.git # Link to remote repoCreate and switch to a new branch
git checkout -b new-branch-name # Create and switch to a new branchSwitch to an existing branch
git checkout branch-name # Switch to another branchMerge a branch into current branch
git merge branch-name # Merge changes from specified branchDelete a branch
git branch -d branch-name # Delete a local branch