Common Git Commands
Git is a powerful version control system widely used in software development. Here are some common commands that every developer should know:
-
git init
- Initializes a new Git repository in the specified directory. -
git clone [url]
- Creates a copy of a remote repository on your local machine. -
git add [file]
- Stages changes in the specified file(s) for the next commit. -
git commit -m "[message]"
- Commits the staged changes with a descriptive message. -
git status
- Shows the status of your working directory and staging area. -
git branch
- Lists all branches in your repository, highlighting the current branch. -
git checkout [branch]
- Switches to the specified branch, updating the working directory. -
git merge [branch]
- Merges changes from the specified branch into the current branch. -
git push
- Sends your commits to the remote repository. -
git pull
- Fetches and integrates changes from the remote repository to your local branch.
Mastering these commands can significantly enhance your efficiency in software development and collaboration.