Pushing a Change
Goals
- Learn how to push a change to a remote repository.
Since bare repositories are usually shared on some sort of network server, it is usually difficult to cd into the repo and pull changes. So we need to push our changes into other repositories.
Let’s start by creating a change to be pushed. Edit the README and commit it
README
This is the Hello World example from the git tutorial.
(Changed in the original and pushed to shared)
Execute:
git checkout master
git add README
git commit -m "Added shared comment to readme"
Now push the change to the shared repo.
Execute:
git push shared master
shared is the name of the repository receiving the changes we are pushing. (Remember, we added it as a remote in the previous lab.)
Output:
$ git push shared master
To ../hello.git
b39ac69..78e3ce2 master -> master
NOTE: We had to explicitly name the branch master that was receiving the push. It is possible to set it up automatically, but I never remember the commands to do that. Check out the “Git Remote Branch” gem for easy management of remote branches.
当前内容版权归 gitimmersion 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 gitimmersion .