Tuesday, July 10, 2012


Pushing and pulling is very closely related to remotes.  Remotes are versions of a project that are on the internet or hosted on some other network.  Pulling allows users to take the information or code written on the remotes and bring it to their local computers.  Pushing allows the user to add the changes that they have made to the program to the main branch that the program is hosted on.  Pushing occurs after you commit and when you want to share your changes. It pretty much just allows people to edit the project and on their own computer and then give it back to everyone, so they can then edit it from there. It's convenient for collaborative groups. 

To Pull:
To set up a local master branch and track the changes of the master branch use the command git clone in the terminal.
• To get all the data from the repository that the user doesn't have use the command $ git fetch [remote-name] in the terminal.
This will allow the the user references to all the branches from the remote which the user can inspect or merge at any time.  
• If a user wants to get any new work that has been pushed to the server since he/she has last cloned/fetched from it, use the command git fetch origin
This command will only pull the data to your local repository, it will not merge any of the new changes into your work.
• To get data from the originally cloned server and to have the new data merged into the code you are currently working on use the command git pull

To Push:
• To push your project upstream to share use the command git push [remote-name] [branch-name]
To push your master branch to your origin server use the command $ git push origin master (origin and master are the set defaults)
This will only work if you have write access and nobody has pushed their changes before you. If someone else has pushed their changes upstream before you, your push will be rejected.  You will have to pull their work down, incorporate it, and push again.