How to Use Git from the Command Line
· Category: VS Code & Developer Tools
Short answer
Git is a distributed version control system managed from the command line. Learning the core commands lets you track changes, collaborate, and maintain project history.
Steps
- Install Git from git-scm.com and verify with
git --version. - Clone a repository with
git clone <url>. - Stage changes with
git add <file>orgit add .for all files. - Commit changes with
git commit -m "message". - Push to remote with
git pushand pull updates withgit pull.
Tips
- Use
git statusfrequently to see the current state of your working directory. - Write commit messages in the imperative mood: "Add feature" not "Added feature".
- Configure your name and email with
git config --global user.nameanduser.email.
Common issues
- Merge conflicts occur when the same line is edited; resolve them manually in the file.
- Authentication errors often mean your credentials or SSH keys need updating.