Push and Pull


15 min.   |   Beginner  

Check the Current State of the Repository

Use the git status command to see which files have been changed, added, or deleted in your repository since your last local edit.

git status

Commit Your Work

The git commit -m command allows you to save a snapshot of your staged changes with a meaningful message describing what you did.

git add .
git commit -m "your message here"

Notice in the figure above that these changes remain stashed as uncommitted modifications on your local machine. These do not get sent to the remote repository yet.

Push to Remote

Upload your local commits to the remote GitHub repository using git push. This way, your files are saved remotely, and others can view and build on your changes.

git push origin main  

You can also replace main with your branch name if you are working from a branch.

Pull from Remote

Download and merge the latest changes from the remote repository into your local machine using git pull.

WarningPull Might Trigger Merge Conflicts!

If your teammates or other collaborators made changes to the same files, Git might ask you to resolve a conflict before finishing the pull.

git pull