Skip to content

Instantly share code, notes, and snippets.

@fightbulc
Created November 5, 2012 14:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fightbulc/4017522 to your computer and use it in GitHub Desktop.
Save fightbulc/4017522 to your computer and use it in GitHub Desktop.
Git local/remote repo handling

Remote Server Data

Remote address: 150.0.0.1
Remote user: joe

Setup a remote repo

Remote repos should be able to accept push from other repos. Therefore, we need to setup a bare repo:

mkdir foobar.git
cd foobar.git
git --bare init

Setup a local repo w/ tracking

# Start a local repo
git init

# Add remote
git remote add origin master joe@150.0.0.1:foobar.git

# Stage all files for initial
git add .

# Commit all staged files
git commit -m "initial"

# push files upstream and tell local git to connect/track the current branch with the remote one.
# this enables us for the future doing only: git push/pull vs. git push/pull origin master
git push -u origin master

Remarks for tracking

By default git push pushes to all name matching remote branches. To enable git push/pull to act as one might assume do the following:

git config --global push.default upstream

if you forgot to track, do it now (based on the current branch)

git branch -u origin/master

checkout a remote branch and track it

git checkout -t origin/branchName

now you could make changes to your local copy of "branchName" and push it back via:

git push

Current status overview in short

git status -sb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment