Now that we've introduced GitHub as your remote collaboration hub, let's dive into the fundamental language that makes it all possible: Git commands. Think of Git as the engine under the hood, and these commands are the steering wheel, accelerator, and brakes that let you navigate your project's history. We'll cover the most essential commands you'll use daily.
The git init command is your starting point for any new project that you want to track with Git. It initializes an empty Git repository in your current directory, creating a hidden .git folder where all the magic happens – storing your project's history and metadata.
git initThe git clone command is your gateway to existing projects. Whether it's a project on GitHub or another Git hosting service, this command downloads a complete copy of the repository, including its entire history, to your local machine. You'll typically use this when you want to start working on a project that's already been set up.
git clone <repository_url>After making changes to your files, you need to tell Git which of those changes you want to include in your next snapshot. git add stages these changes. It doesn't save them permanently yet, but it marks them for inclusion in the next commit. You can add specific files or all changes at once.
git add <file_name>
git add .Once your changes are staged with git add, you can permanently record them with git commit. Each commit is a snapshot of your project at a specific point in time. It's crucial to write clear and concise commit messages that explain what changes were made. This is the core of tracking your project's evolution.
git commit -m "Your descriptive commit message here"To see the history of your commits, the git log command is your best friend. It displays a list of all commits, showing their unique hash, author, date, and commit message. This is invaluable for understanding how your project has progressed and for pinpointing when certain changes were introduced.