Pushing to remotes

Intermediate Git

George Boorman

Curriculum Manager, DataCamp

Pulling from a remote

pull from a remote repository

Intermediate Git

Pushing to a remote

push to a remote

Intermediate Git

git push

  • Save changes locally first!
git push remote local_branch
  • Push into remote from local_branch

  • Push changes into origin from the local repo's main branch

git push origin main
Intermediate Git

Push/pull workflow

pull from remote into local repo

Intermediate Git

Push/pull workflow

work on project locally

Intermediate Git

Push/pull workflow

push updated local repository to the remote

Intermediate Git

Pushing first

  • Pushing main to the remote before pulling
git push origin main
Intermediate Git

Remote/local conflicts

git push origin main rejection output

Intermediate Git

Remote/local conflicts

git push origin main rejection output annotated remote URL

Intermediate Git

Remote/local conflicts

git push origin main rejection output annotated outcome

Intermediate Git

Remote/local conflicts

git push origin main rejection output annotated reasons and suggestions

Intermediate Git

Avoiding a conflict

  • Pull from the remote first
git pull origin main

git_pull_nano_editor.gif

Intermediate Git

Pulling without editing

git pull --no-edit origin main
  • Not recommended, unless we are very confident in the history of our project!
Intermediate Git

Pushing a new local branch

  • Working in hotfix branch locally

  • hotfix does not exist in the remote

Intermediate Git

Creating a new remote branch

  • hotfix only exists locally
git push origin hotfix
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 8 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 349 bytes | 349.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
remote: 
remote: Create a pull request for 'hotfix' on GitHub by visiting:
remote:      https://github.com/datacamp/project/pull/new/hotfix
remote: 
To https://github.com/datacamp/project
 * [new branch]      hotfix -> hotfix
branch 'hotfix' set up to track 'origin/hotfix'.
Intermediate Git

Let's practice!

Intermediate Git

Preparing Video For Download...