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.
Finally, if you're working with a remote repository (like one on GitHub), you'll want to share your committed changes with others and back them up. This is where git push comes in. It uploads your local commits to the remote repository.
git push origin <branch_name>Here, origin usually refers to your remote repository's default name, and <branch_name> is the branch you're currently working on (often main or master for beginners).