Push
Git push is used to push commits made on your local branch to a remote repository.
git push <remote> <branch>
As with the git pull
command, it is a prerequisite that "tracking" is configured for a remote branch.
We will get an error, if that is the case.
Exercise: Push a change to the remote repository
- Navigate to the
remote-git
repository.- Checkout the
feature
branch.- Append
Change from remote
to theREADME.md
file.- Commit the change with message
Change from remote
.- Push the changes to the remote repository.
- Validate the change made in the remote repository.
Solution: Push a change to the remote repository
Navigate to the remote-git
repository.
git checkout feature
echo "Change from remote" >> README.md
git add README.md
git commit -m "Change from remote"
git push
Validate the change made in the remote repository. First navigate to the learn-git
repository.
git checkout feature
git log --oneline --graph