Git for steve the idiot

By | April 5, 2016

Add git to an existing project

Create a new repo on bitbucket

2016-04-05 16_46_17-Create a repository — Bitbucket

cd to project you wish to git...
# cd /usr/local/www/apache24/data/project123
# git init Initialized empty Git repository in /usr/local/www/apache24/data/project123/.git/
# git remote add origin https://sscotter@bitbucket.org/sscotter/test2016-05-05.git
# git add .
# git status
git commit -m "First commit"
# git push origin master

Add 2nd machine to repo

cd to a directory of your choice. When you clone the repo, it’ll create a directory where you are with the name of the repo. (eg cd c:\test; git clone https://sscotter@bitbucket.org/sscotter/test2016-05-05.git results in a the project landing in C:\test\test2016-05-05

# git clone https://sscotter@bitbucket.org/sscotter/test2016-05-05.git

If required, move / rename the directory to fit you schema.

Updating repo after having made changes…

# git status

Changes not staged for commit:
 (use "git add/rm <file>..." to update what will be committed)
 (use "git checkout -- <file>..." to discard changes in working directory)

 modified: common/models/Messages.php
 modified: common/models/Numbers.php
 modified: frontend/controllers/ConsignmentController.php
 modified: frontend/views/consignment/_form.php

# git add common/models/Messages.php common/models/Numbers.php frontend/controllers/ConsignmentController.php frontend/views/consignment/_form.php
(sure there is a better way?!?)

# git status On branch master
Your branch is up-to-date with 'origin/master'.
Changes to be committed:
 (use "git reset HEAD <file>..." to unstage)

 modified: common/models/Messages.php
 modified: common/models/Numbers.php
 modified: frontend/controllers/ConsignmentController.php
 modified: frontend/views/consignment/_form.php

Changes not staged for commit:
 (use "git add/rm <file>..." to update what will be committed)
 (use "git checkout -- <file>..." to discard changes in working directory)

 deleted: backend/web/.gitignore
 modified: composer.lock
 deleted: frontend/web/.gitignore

Untracked files:
 (use "git add <file>..." to include in what will be committed)

 backend/web/.gitignore.wtf
 backend/web/dbg-wizard.php
 frontend/web/.gitignore.wtf
 frontend/web/dbg-wizard.php

# git commit

(Fill in a message)

# git push
warning: push.default is unset; its implicit value has changed in
Git 2.0 from ‘matching’ to ‘simple’. To squelch this message
and maintain the traditional behavior, use:

git config –global push.default matching

To squelch this message and adopt the new behavior now, use:

git config –global push.default simple

When push.default is set to ‘matching’, git will push local branches
to the remote branches that already exist with the same name.

Since Git 2.0, Git defaults to the more conservative ‘simple’
behavior, which only pushes the current branch to the corresponding
remote branch that ‘git pull’ uses to update the current branch.

See ‘git help config’ and search for ‘push.default’ for further information.
(the ‘simple’ mode was introduced in Git 1.7.11. Use the similar mode
‘current’ instead of ‘simple’ if you sometimes use older versions of Git)

Password for ‘https://sscotter@bitbucket.org’:

Pulling updates down from the repo

# git pull origin master

Category: Git