lab 22 Pushing a Change

Goals

Since public 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.

NOTE: Still in the hello repo

Adding the shared repo as a remote01

First, we need to add shared_hello as a remote repository of hello.

Execute:

git remote add shared ../shared_hello.git
git remote show shared

Output:

$ git remote add shared ../shared_hello.git
$ git remote show shared
* remote shared
  Fetch URL: ../shared_hello.git
  Push  URL: ../shared_hello.git
  HEAD branch: master
  Remote branches:
    greet  new (next fetch will store in remotes/shared)
    master new (next fetch will store in remotes/shared)
  Local refs configured for 'git push':
    greet  pushes to greet  (up to date)
    master pushes to master (up to date)

Pushing to the shared repo02

Push the change to the shared repo.

Execute:

git push --set-upstream shared master

Output:

$ git push --set-upstream shared master
Counting objects: 3, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 370 bytes | 0 bytes/s, done.
Total 3 (delta 1), reused 0 (delta 0)
To ../shared_hello.git
   37bb26f..4352eb5  master -> master
Branch master set up to track remote branch master from shared.

NOTE: Now that shared/master as been set as the "upstream" branch of the local master branch, next push operations can be done using the shorter command:

git push

Table of Contents