Labs ICT
โญ Pro Login

Push Changes

You've set up your remote repository, and now it's time to share your work with others. Git push commands are like sending your latest code changes to the shared branch where your team can see them. This section covers pushing your changes, setting up upstream tracking, and even managing branch deletions remotely - all essential skills for effective team collaboration.

Pushing to a Remote Branch

Once you're ready to share your work, use git push origin branch-name to send your local commits to the remote repository. This makes your code changes available to everyone on your team.

$ git push origin feature-login
$ git log --oneline --graph --decorate
Try it Yourself โ†’

Setting Upstream Tracking

When you use git push -u origin branch-name, Git sets up upstream tracking. This remembers which remote branch to push to in the future, and also automatically fetches when you do a pull. It's a convenience feature that saves you from typing the full remote path each time.

$ git push -u origin main
$ git status
Try it Yourself โ†’

Deleting Branches Remotely

When a feature is complete or a branch is merged, you can delete it remotely with git push origin --delete branch-name. This keeps your remote repository clean and removes branches that are no longer needed.

$ git push origin --delete feature-login
Try it Yourself โ†’

๐Ÿงช Quick Quiz

Which command uploads local commits to a remote repository?