Getting Started with GitHub: A Beginner's Guide to Version Control and Collaboration

Understanding the Git Workflow: Add, Commit, Push

Section 5

Your First Steps with Git: Installation and Basics

Getting Started with GitHub: A Beginner's Guide to Version Control and CollaborationYour First Steps with Git: Installation and Basics

You've installed Git and are ready to start making changes to your projects. But how do you tell Git what you've done and save it? This is where the core Git workflow comes in: add, commit, and push. Think of it as taking snapshots of your project's progress.

The first step in this workflow is staging your changes. When you make modifications to files, Git tracks these changes but doesn't automatically include them in your next snapshot. You need to explicitly tell Git which changes you want to include. This is done using the git add command.

git add <file_name>

If you want to add all the modified files in your current directory and its subdirectories, you can use a wildcard:

git add .

After staging your changes with git add, you've prepared them for the next step: committing. A commit is like a save point for your project. It's a snapshot of all the staged changes at a particular moment. Each commit has a unique identifier and a message that describes what was changed. This message is crucial for understanding the history of your project.

git commit -m "Your descriptive commit message here"

The -m flag allows you to provide the commit message directly on the command line. Choose your messages wisely – they should be concise yet informative, explaining the purpose of the changes.

チャプターへ戻る