Pushing changes to GitHub involves a few steps:
Stage Changes: First, we need to tell Git which changes we want to include in our next commit. We do this by staging the changes with the command git add -A
. This command stages all changes in our working directory. We have already covered this in the previous chapter.
Commit Changes: After staging our changes, we commit them with the command git commit -m "Our commit message"
. The commit message should briefly describe what changes we made. We have also covered this in the previous chapter.
Push Changes: Finally, we push our committed changes to GitHub with the command git push origin <branch-name>
. The default branch name is usually main
. However, it's not recommended to push changes directly to the main
branch. Instead, we should create a new branch for our changes and push them to that branch. If we are working on a different branch, we need to specify that branch name instead like this
Here new-branch
is the name of the branch we want to push our changes to.
And that's it! We've successfully pushed our changes to GitHub. Now, anyone who has access to our GitHub repository can see and pull our latest changes