User Tools

Site Tools


This is an old revision of the document!


Make the clone at the remote repository.

git clone
git remote add upstream git://

Enter a comment for the commit. See section 2.7.2 here.

git commit -a

Double checking the alias names…

$ git remote -v
origin (fetch)
origin (push)
upstream        git:// (fetch)
upstream        git:// (push)

The push that worked from within the local directory:

git push origin

Make a local clone of an existing remote project

From the parent directory:

git clone python-interview
cd python-interview

When it's time to commit

1. Check which files are staged for commit.

git status

2. Then, when you're ready to commit locally,

git commit -a -m "Some useful comment"

3. When you're ready to push a local commit to a remote one…

git push -u origin master


git push

Creating a new remote repository from an existing local one

I created hexbright-factory at Then, to create a new repository on the command line at the local computer:

git init
git add
git commit -m "first commit"
git remote add origin
git push -u origin master

Creating a new remote repository from an existing local one

I created wine-tasting at Then, to create a new repository on the command line at the local computer:

~$ mkdir wine-tasting
~$ cd wine-tasting/
wine-tasting$ vim
wine-tasting$ vim LICENSE.txt
wine-tasting$ git init
wine-tasting$ git add
wine-tasting$ git add LICENSE.txt
wine-tasting$ git add
wine-tasting$ git add
wine-tasting$ git commit -m "first commit"
wine-tasting$ git remote add origin
wine-tasting$ git push -u origin master

Renaming branches

To rename a remote branch (where “origin” is the name of the remote repo):

  1. Rename the local one.
  2. Push the deletion of the old name.
  3. Push the new name.
  4. git remote prune origin

When someone else renamed a remote branch:

$ git fetch --all  # TODO investigate why fetch
$ git remote prune origin  # (where origin is the name of the shared repo)

Now I should see “remotes/origin/roku_dev” gone, and “remotes/origin/SDK_4.2.P2_Roku” appear.

I still have a local branch called “roku_dev” and it's set to track “remotes/origin/roku_dev”. Since “remotes/origin/roku_dev” is no longer there, if I try “git pull” on that branch it will say remote reference doesn't exist.

Since I don't have any changes on that local branch that I haven't pushed up to the server before the name change, I can safely delete this local branch, and create a new local branch from “remotes/origin/SDK_4.2.P2_Roku”.

Changing a local branch without regard to remote branch

$ git checkout -b branch_name
Switched to a new branch 'branch_name'

That was the same as “git branch branch_name; git checkout branch_name”

Changing a local branch to a new remote branch

This'll work if you don't have a local branch with that name already.

$ git checkout --track origin/branch_name

Making the current local branch track a new remote branch

$ git branch -u origin/branch_name

git at

I created a remote git repo at dlma like so:

At the server:

git$ mkdir testcode.git
git$ cd testcode.git/
testcode.git$ git init --bare

Then, at the local computer:

testcode$ git init
Initialized empty Git repository in /home/David/testcode/.git/
testcode$ git add .
testcode$ git commit -m "first commit"
testcode$ git remote add origin ssh://
testcode$ git push origin master

I could've use gitweb but I used GitHub-like gitlist at

todo-git.1489171818.txt.gz · Last modified: 2023/04/12 20:44 (external edit)