Setting up Git git config --global user.name "Your Name"
: Set your Git usernamegit config --global user.email "[email protected]"
: Set your Git email addressgit config --list
: List all Git configuration settings
Creating a new repositorygit init
: Create a new local repositorygit clone [url]
: Clone an existing repository from a remote source
Adding and committing changesgit add [file]
: Add changes to the staging areagit add .
: Add all changes to the staging areagit commit -m "Commit message"
: Commit changes to the local repository with a message
Working with branchesgit branch
: List all branchesgit branch [branch-name]
: Create a new branchgit checkout [branch-name]
: Switch to a specific branchgit merge [branch-name]
: Merge changes from a specific branch into the current branchgit push origin [branch-name]
: Push changes to a remote repository
Working with remote repositoriesgit remote add origin [url]
: Add a remote repositorygit pull
: Fetch and merge changes from a remote repositorygit push
: Push changes to a remote repositorygit remote -v
: List all remote repositories
Other helpful commandsgit status
: Show the status of your repositorygit log
: Show the commit history of your repositorygit diff [file]
: Show the changes made to a specific file.
These are some of the most commonly used Git commands. I hope this cheat sheet helps you in your Git journey!
Leave a Reply