Git - Remote

Working with Remote Git Repositories

# show origin with URL
git remote -v
# update remote tracking branches
git remote update
# see changes/diffs between upstream work and local work
git log -p ..@{u}
# integrate downloaded changes
git merge @{u}
# or rebase your work with upstream changes
git rebase @{u}
# to speed up the integration of remote work you might use:
git pull origin yourbranch
# this will fetch from origin and merge (ff) your local branch "yourbranch" 
# upload all changes you made the steps before to upstream again
git push
# delete a branch local and remote
git branch delete feature/bugfix
git push origin --delete feature/bugfix
# get rid of stale remote branches - delete local branches referencing remote branches
# which don't exist anymore
git remote prune origin

Creating a Remote Repo from a Local One:

If you were working with your local Git repo and you want to have a central remote repo somewhere else here are the steps to make that happen. Just to be precise: in this example, the “remote” repo will reside in an nfs-mounted directory so we can access it via the file directive.

  1. create a bare Git repo where you want your central “remote” repo
  2. push your local repo to the remote one
  3. make the remote repo the origin of your local repo

The commands to run:

# create the "remote" repo to be:
cd /nfs/vcs/
mkdir example.git
cd example.git
git init --bare
# push your local repo to the new origin:
cd ~/vcs/example
git push --all /nfs/vcs/example.git/
git remote add origin file:///nfs/vcs/example.git
git remote -v
origin  file:///nfs/vcs/example.git (fetch)
origin  file:///nfs/vcs/example.git (push)
# make sure your new remote is set as the default remote:
git branch --set-upstream master origin/master

To use the new remote repo just clone it.

howto/git/git_remote.txt · Last modified: 2016-06 by tb
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0 ipv6 ready