Do not rebase commits that you have pushed to a public repository.


Git Notes

I need to understand git better & how its used here.

Resources

Aliases

alias dskill="find . -name '*.DS_Store' -type f -delete"
alias refresh="git checkout master && dskill && git pull && git fetch -p"

Github Flow

Figure

git clone {some-repo} #

git branch -a # shows all local and remote branches
git branch -r # shows only remote branches
git fetch -p  # Prune any branches that no longer exist on the remote branch

git branch -b 
git checkout -b feature/some_descriptive_branch_name
git push

Learning Git

1. Create a rep, add a file

git checkout master
git pull

2. Create a Branch

git checkout -b some_branch_name

3. Pull requests


once you are on branch:

git fetch origin master
merge feature to master -> git merge feature master
merge master to feature -> git merge master feature


Listen to this from MobileCouch.

Are we in a git repo.

# Are we in a git repo, if not *Boom* ?
#
git rev-parse --show-toplevel 2>&1 >/dev/null|| exit 1

ROOT=$(git rev-parse --show-toplevel)

Tags

Delete local & remote

# delete remotely
git push --delete origin tagName
# delete tag in your local
git tag -d tagName

Plugins

Then

git config --global core.pager "diff-so-fancy | less --tabs=4 -RFX"
git config --global color.ui true

git config --global color.diff-highlight.oldNormal    "red bold"
git config --global color.diff-highlight.oldHighlight "red bold 52"
git config --global color.diff-highlight.newNormal    "green bold"
git config --global color.diff-highlight.newHighlight "green bold 22"

git config --global color.diff.meta       "11"
git config --global color.diff.frag       "magenta bold"
git config --global color.diff.commit     "yellow bold"
git config --global color.diff.old        "red bold"
git config --global color.diff.new        "green bold"
git config --global color.diff.whitespace "red reverse"

Notes

Heck, everyone loves a directed graph.

git config --global user.name "Rik Watson"
git config --global user.email rik.watson@asos.com
...
git checkout master
git pull
git checkout -b some_branch_name
vi some_file(s)
git status
git diff
git add .
git commit -m "Some suitable comment"
git push origin ?????

Mirroring a repository in another location

TODO: I should update my git repos to have a ./read-only folder for repos that I shall only ever mirror, not modify.

Method from GitHub. If you want to mirror a repository in another location, including getting updates from the original, you can clone a mirror and periodically push the changes.

  1. Create a bare mirrored clone of the repository.
git clone --mirror https://github.com/exampleuser/repository-to-mirror.git
  1. Set the push location to your mirror.
cd repository-to-mirror.git
git remote set-url --push origin https://github.com/exampleuser/mirrored

As with a bare clone, a mirrored clone includes all remote branches and tags, but all local references will be overwritten each time you fetch, so it will always be the same as the original repository. Setting the URL for pushes simplifies pushing to your mirror. To update your mirror, fetch updates and push.

git fetch -p origin
git push --mirror

A/C Create on GitLab, rikwatson.

Get workflow for a single developer sorted & documents the small subset of commands I need to learn.

Ultra Basic Workflow

Shallow clone

if $(git rev-parse --is-shallow-repository); then
    git fetch --shallow
fi

Passwords

Store passwords in ~/.netrc e.g.

machine github.com
       login rikwatson
       password thisismypassword

.gitignore

Globally ignore macOS .DS_Store files via:

echo .DS_Store >> ~/.gitignore_global
git config --global core.excludesfile ~/.gitignore_global

Nice log output for HockeyApp etc

git log --graph --pretty=format:'%h -%d %s <%an>' --abbrev-commit #{ENV['GIT_PREVIOUS_SUCCESSFUL_COMMIT'] || 'HEAD^^^^^'}..HEAD
git log --graph --pretty=format:'%h -%d %s <%an>' --abbrev-commit #{$GIT_PREVIOUS_SUCCESSFUL_COMMIT || 'HEAD^^^^^'}..HEAD
git log --graph --pretty=format:'%h -%d %s <%an>' --abbrev-commit e4a01444630800f7a2f936683805622633a2c206...HEAD

GIT_PREVIOUS_SUCCESSFUL_COMMIT is set by Jenkins.

Git Branching - local & remote

Add notes from here

git branch
git remote show origin
git branch -a # shows all local and remote branches
git branch -r # shows only remote branches
git remote show origin
git ls-remote —heads origin

git Add to general git notes

git log --merges --pretty=format:'%h -%d %s <%an>' --abbrev-commit #{ENV['GIT_PREVIOUS_SUCCESSFUL_COMMIT']}..HEAD | grep 'Merge pull' || true
``


@TODO


—

## Jenkins

This is the command from [Jenkins](/jenkins) to update itself.

Building on master in workspace /Users/Shared/Jenkins/Home/jobs/Android TEST variant/workspace

git rev-parse –is-inside-work-tree # timeout=10 Fetching changes from the remote Git repository git config remote.origin.url https://github.com/myteam/my-native-android # timeout=10 Fetching upstream changes from https://github.com/myteam/my-native-android git –version # timeout=10 using .gitcredentials to set credentials git config –local credential.username email@emaple.com # timeout=10 git config –local credential.helper store –file=/Users/Shared/Jenkins/tmp/git8723421402276973754.credentials # timeout=10 git -c core.askpass=true fetch –tags –progress https://github.com/myteam/my-native-android +refs/heads/:refs/remotes/origin/ git config –local –remove-section credential # timeout=10 git rev-parse refs/remotes/origin/develop^{commit} # timeout=10 git rev-parse refs/remotes/origin/origin/develop^{commit} # timeout=10 Checking out Revision 3c5a8e26146661629d577d2e95eb346e1b473116 (refs/remotes/origin/develop) git config core.sparsecheckout # timeout=10 git checkout -f 3c5a8e26146661629d577d2e95eb346e1b473116 git rev-list a5cd8ad542ba42f6bc341ecdabc24ed9f4748aa8 # timeout=10 ```

Which is odd, I would have expected a simple git pull to work.

Getting nice release notes from git in jenkins

Reading List

GitFlow

gitflow is the definitive workflow for git. No compelling reason to use anthing else.

Unless githubflow works for you, introduction via GitHub.

More on github flow.

Useful commands

Fork & keep in sync

For CI reasons it’s useful to have a read-only fork of a repositry which is kept in sync with its master.

Mirroring a repo

Not cloning.

  • https://chrisdown.name/2013/07/05/setting-up-local-github-mirror-with-cgit-git-daemon.html
  • http://stackoverflow.com/questions/11370239/creating-an-official-github-mirror
  • http://stackoverflow.com/questions/15871787/automatically-mirroring-a-github-repo
  • https://github.com/beefsack/git-mirror

Password caching

On MacOS, take a look here, basicall git config --global credential.helper osxkeychain

Git Submodules

After your first checkout:

git submodule init
git submodule update

To add a submodule:

git submodule add https://github.com/username/path

To update all submodules to their latest commits:

git submodule foreach git pull origin master

Setup github

I’m rikwatson on GitHub & A/C Create on GitLab, also rikwatson

A nice branching method here

  • GitBox
  • gist.io Very cool
  • http://robots.thoughtbot.com/post/4747482956/streamline-your-git-workflow-with-aliases
  • https://sandofsky.com/blog/git-workflow.html

[[gists]]

Mirroring a repository

To make an exact duplicate, you need to perform both a bare-clone and a mirror-push.

Open up the command line, and type these commands:

git clone --bare https://github.com/exampleuser/old-repository.git
# Make a bare clone of the repository

cd old-repository.git
git push --mirror https://github.com/exampleuser/new-repository.git
# Mirror-push to the new repository

cd ..
rm -rf old-repository.git
# Remove our temporary local repository

If you want to mirror a repository in another location, including getting updates from the original, you can clone a mirror and periodically push the changes.

git clone --mirror https://github.com/exampleuser/repository-to-mirror.git
# Make a bare mirrored clone of the repository

cd repository-to-mirror.git
git remote set-url --push origin https://github.com/exampleuser/mirrored
# Set the push location to your mirror

As with a bare clone, a mirrored clone includes all remote branches and tags, but all local references will be overwritten each time you fetch, so it will always be the same as the original repository. Setting the URL for pushes simplifies pushing to your mirror. To update your mirror, fetch updates and push, which could be automated by running a cron job.

git fetch -p origin
git push --mirror

$ mkdir git-cli
$ cd git-cli/
$ ls

$ echo "test" > first.txt

$ ls
first.txt

$ git status
fatal: Not a git repository (or any of the parent directories): .git

$ git init
Initialized empty Git repository in C:/_root/git-cli/.git/

$ git st
On branch master

Initial commit

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

        first.txt

nothing added to commit but untracked files present (use "git add" to track)

$ git add first.txt

$ git st
On branch master

Initial commit

Changes to be committed:
  (use "git rm --cached <file>..." to unstage)

        new file:   first.txt


$ echo "asdadasd" > first.txt

$ git status
On branch master

Initial commit

Changes to be committed:
  (use "git rm --cached <file>..." to unstage)

        new file:   first.txt

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

        modified:   first.txt


$ git diff --staged
diff --git a/first.txt b/first.txt
new file mode 100644
index 0000000..9daeafb
--- /dev/null
+++ b/first.txt
@@ -0,0 +1 @@
+test

$ git diff
diff --git a/first.txt b/first.txt
index 9daeafb..80939b6 100644
--- a/first.txt
+++ b/first.txt
@@ -1 +1 @@
-test
+asdadasd

$ git add .

$ git st
On branch master

Initial commit

Changes to be committed:
  (use "git rm --cached <file>..." to unstage)

        new file:   first.txt


$ git diff --staged
diff --git a/first.txt b/first.txt
new file mode 100644
index 0000000..80939b6
--- /dev/null
+++ b/first.txt
@@ -0,0 +1 @@
+asdadasd

$ git commit -m "Add first.txt"
[master (root-commit) 72da1cf] Add first.txt
 1 file changed, 1 insertion(+)
 create mode 100644 first.txt

$ git st
On branch master
nothing to commit, working tree clean

$ git hist
* 72da1cf 2017-01-20 | Add first.txt (HEAD -> master) [Rob Bell]

$ git st
On branch master
nothing to commit, working tree clean

$ git remote add origin https://github/robbell/git-cli

$ git push -u origin master
fatal: unable to access 'https://github/robbell/git-cli/': Couldn't resolve host 'github'

$ git remote add origin https://github.com/robbell/git-cli
fatal: remote origin already exists.

$ git remote remove origin

$ git remote add origin https://github.com/robbell/git-cli

$ git push -u origin master
Counting objects: 3, done.
Writing objects: 100% (3/3), 220 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To https://github.com/robbell/git-cli
 * [new branch]      master -> master
Branch master set up to track remote branch master from origin.

$ echo "second change" > second.txt

$ echo "second change" > first.txt

$ git st
On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        modified:   first.txt

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

        second.txt

no changes added to commit (use "git add" and/or "git commit -a")

$ git add .

$ git commit -m "Add second.txt"
[master af41b73] Add second.txt
 2 files changed, 2 insertions(+), 1 deletion(-)
 create mode 100644 second.txt

$ git st
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
  (use "git push" to publish your local commits)
nothing to commit, working tree clean

$ git hist
* af41b73 2017-01-20 | Add second.txt (HEAD -> master) [Rob Bell]
* 72da1cf 2017-01-20 | Add first.txt (origin/master) [Rob Bell]

$ git pull
Already up-to-date.

$ git push
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 264 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To https://github.com/robbell/git-cli
   72da1cf..af41b73  master -> master


Listen to this from MobileCouch.

Mirroring a repository in another location

If you want to mirror a repository in another location, including getting updates from the original, you can clone a mirror and periodically push the changes.

Open Terminal.

Create a bare mirrored clone of the repository.

git clone --mirror https://github.com/exampleuser/repository-to-mirror.git

Set the push location to your mirror.

cd repository-to-mirror.git
git remote set-url --push origin https://github.com/exampleuser/mirrored

As with a bare clone, a mirrored clone includes all remote branches and tags, but all local references will be overwritten each time you fetch, so it will always be the same as the original repository. Setting the URL for pushes simplifies pushing to your mirror. To update your mirror, fetch updates and push.

git fetch -p origin
git push --mirror

A/C Create on GitLab, rikwatson.

Get workflow for a single developer sorted & documents the small subset of commands I need to learn.


mkdir ./repositry
cd ./repositry
git init
git config user.name "Rik Watson"
git config user.email "rik@plancd.com"

Ultra Basic Workflow

git init
git Add -A
git commit -m "Initial commit
git remote add origin get@github.com:rikwatson/repo-name.git
git push -u origin master
# Do some real work.
git add changed.file another_changed.file
git commit -m "suitable comment"
get push -u origin master

Shallow clone

# To clone repo foo.git with branch bar do:

git clone --depth 1 https://path/to/repo/foo.git -b bar

Passwords

Store passwords in ~/.netrc e.g.

machine github.com
       login rikwatson
       password thisismypassword

.gitignore

Globally ignore macOS .DS_Store files via:

echo .DS_Store >> ~/.gitignore_global
git config --global core.excludesfile ~/.gitignore_global

Nice log output for HockeyApp etc

git log --graph --pretty=format:'%h -%d %s <%an>' --abbrev-commit #{ENV['GIT_PREVIOUS_SUCCESSFUL_COMMIT'] || 'HEAD^^^^^'}..HEAD
git log --graph --pretty=format:'%h -%d %s <%an>' --abbrev-commit #{$GIT_PREVIOUS_SUCCESSFUL_COMMIT || 'HEAD^^^^^'}..HEAD
git log --graph --pretty=format:'%h -%d %s <%an>' --abbrev-commit e4a01444630800f7a2f936683805622633a2c206...HEAD

GIT_PREVIOUS_SUCCESSFUL_COMMIT is set by Jenkins.

Jenkins

This is the command from Jenkins to update itself.

Building on master in workspace /Users/Shared/Jenkins/Home/jobs/Android TEST variant/workspace
 > git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > git config remote.origin.url https://github.com/myteam/my-native-android # timeout=10
Fetching upstream changes from https://github.com/myteam/my-native-android
 > git --version # timeout=10
using .gitcredentials to set credentials
 > git config --local credential.username email@emaple.com # timeout=10
 > git config --local credential.helper store --file=/Users/Shared/Jenkins/tmp/git8723421402276973754.credentials # timeout=10
 > git -c core.askpass=true fetch --tags --progress https://github.com/myteam/my-native-android +refs/heads/*:refs/remotes/origin/*
 > git config --local --remove-section credential # timeout=10
 > git rev-parse refs/remotes/origin/develop^{commit} # timeout=10
 > git rev-parse refs/remotes/origin/origin/develop^{commit} # timeout=10
Checking out Revision 3c5a8e26146661629d577d2e95eb346e1b473116 (refs/remotes/origin/develop)
 > git config core.sparsecheckout # timeout=10
 > git checkout -f 3c5a8e26146661629d577d2e95eb346e1b473116
 > git rev-list a5cd8ad542ba42f6bc341ecdabc24ed9f4748aa8 # timeout=10

Which is odd, I would have expected a simple git pull to work.

Getting nice release notes from git in jenkins

git fetch --unshallow
git log --merges  --pretty=format:'%h -%d %s <%an>' --abbrev-commit #{ENV['GIT_PREVIOUS_SUCCESSFUL_COMMIT']}..HEAD | grep " - Merge pull request "

Reading List

GitFlow

gitflow is the definitive workflow for git. No compelling reason to use anthing else.

Unless githubflow works for you, introduction via GitHub.

More on github flow.

Useful commands

Fork & keep in sync.

For CI reasons it’s useful to have a read-only fork of a repositry which is kept in sync with its master.

Terminology

[[Git Terminology]]

Mirroring a repo

Not cloning.

  • https://chrisdown.name/2013/07/05/setting-up-local-github-mirror-with-cgit-git-daemon.html
  • http://stackoverflow.com/questions/11370239/creating-an-official-github-mirror
  • http://stackoverflow.com/questions/15871787/automatically-mirroring-a-github-repo
  • https://github.com/beefsack/git-mirror

Password caching

On MacOS, take a look here, basicall git config --global credential.helper osxkeychain


Setup github

I’m rikwatson on GitHub & A/C Create on GitLab, also rikwatson

A nice branching method here

  • GitBox
  • gist.io Very cool
  • http://robots.thoughtbot.com/post/4747482956/streamline-your-git-workflow-with-aliases
  • https://sandofsky.com/blog/git-workflow.html

Gists

Simple command line access via gist, install via brew install gist

Gists visible on wwwroot in Dropbox. GistBox looks cook.

You can get the RAW text of a GIST via: https://gist.github.com/rikwatson/3688990/raw/

(Possibly even http).

Look at C:\Dropbox\work\chrome_packaged_apps_template_\00-build.py & C:\Dropbox\Public\gists

Mirroring a repository

To make an exact duplicate, you need to perform both a bare-clone and a mirror-push.

Open up the command line, and type these commands:

git clone --bare https://github.com/exampleuser/old-repository.git
# Make a bare clone of the repository

cd old-repository.git
git push --mirror https://github.com/exampleuser/new-repository.git
# Mirror-push to the new repository

cd ..
rm -rf old-repository.git
# Remove our temporary local repository

If you want to mirror a repository in another location, including getting updates from the original, you can clone a mirror and periodically push the changes.

git clone --mirror https://github.com/exampleuser/repository-to-mirror.git
# Make a bare mirrored clone of the repository

cd repository-to-mirror.git
git remote set-url --push origin https://github.com/exampleuser/mirrored
# Set the push location to your mirror

As with a bare clone, a mirrored clone includes all remote branches and tags, but all local references will be overwritten each time you fetch, so it will always be the same as the original repository. Setting the URL for pushes simplifies pushing to your mirror. To update your mirror, fetch updates and push, which could be automated by running a cron job.

git fetch -p origin
git push --mirror

$ mkdir git-cli
$ cd git-cli/
$ ls

$ echo "test" > first.txt

$ ls
first.txt

$ git status
fatal: Not a git repository (or any of the parent directories): .git

$ git init
Initialized empty Git repository in C:/_root/git-cli/.git/

$ git st
On branch master

Initial commit

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

        first.txt

nothing added to commit but untracked files present (use "git add" to track)

$ git add first.txt

$ git st
On branch master

Initial commit

Changes to be committed:
  (use "git rm --cached <file>..." to unstage)

        new file:   first.txt


$ echo "asdadasd" > first.txt

$ git status
On branch master

Initial commit

Changes to be committed:
  (use "git rm --cached <file>..." to unstage)

        new file:   first.txt

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

        modified:   first.txt


$ git diff --staged
diff --git a/first.txt b/first.txt
new file mode 100644
index 0000000..9daeafb
--- /dev/null
+++ b/first.txt
@@ -0,0 +1 @@
+test

$ git diff
diff --git a/first.txt b/first.txt
index 9daeafb..80939b6 100644
--- a/first.txt
+++ b/first.txt
@@ -1 +1 @@
-test
+asdadasd

$ git add .

$ git st
On branch master

Initial commit

Changes to be committed:
  (use "git rm --cached <file>..." to unstage)

        new file:   first.txt


$ git diff --staged
diff --git a/first.txt b/first.txt
new file mode 100644
index 0000000..80939b6
--- /dev/null
+++ b/first.txt
@@ -0,0 +1 @@
+asdadasd

$ git commit -m "Add first.txt"
[master (root-commit) 72da1cf] Add first.txt
 1 file changed, 1 insertion(+)
 create mode 100644 first.txt

$ git st
On branch master
nothing to commit, working tree clean

$ git hist
* 72da1cf 2017-01-20 | Add first.txt (HEAD -> master) [Rob Bell]

DUPLICATE FROM HRE DOWN - PROBABLY


Listen to this from MobileCouch.

Mirroring a repository in another location

If you want to mirror a repository in another location, including getting updates from the original, you can clone a mirror and periodically push the changes.

Open Terminal.

Create a bare mirrored clone of the repository.

git clone --mirror https://github.com/exampleuser/repository-to-mirror.git

Set the push location to your mirror.

cd repository-to-mirror.git
git remote set-url --push origin https://github.com/exampleuser/mirrored

As with a bare clone, a mirrored clone includes all remote branches and tags, but all local references will be overwritten each time you fetch, so it will always be the same as the original repository. Setting the URL for pushes simplifies pushing to your mirror. To update your mirror, fetch updates and push.

git fetch -p origin
git push --mirror

A/C Create on GitLab, rikwatson.

Get workflow for a single developer sorted & documents the small subset of commands I need to learn.

Ultra Basic Workflow

Shallow clone

Passwords

Store passwords in ~/.netrc e.g.

machine github.com
       login rikwatson
       password thisismypassword

.gitignore

Globally ignore macOS .DS_Store files via:

echo .DS_Store >> ~/.gitignore_global
git config --global core.excludesfile ~/.gitignore_global

Nice log output for HockeyApp etc

git log --graph --pretty=format:'%h -%d %s <%an>' --abbrev-commit #{ENV['GIT_PREVIOUS_SUCCESSFUL_COMMIT'] || 'HEAD^^^^^'}..HEAD
git log --graph --pretty=format:'%h -%d %s <%an>' --abbrev-commit #{$GIT_PREVIOUS_SUCCESSFUL_COMMIT || 'HEAD^^^^^'}..HEAD
git log --graph --pretty=format:'%h -%d %s <%an>' --abbrev-commit e4a01444630800f7a2f936683805622633a2c206...HEAD

GIT_PREVIOUS_SUCCESSFUL_COMMIT is set by Jenkins.

Jenkins

This is the command from Jenkins to update itself.

Building on master in workspace /Users/Shared/Jenkins/Home/jobs/Android TEST variant/workspace
 > git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > git config remote.origin.url https://github.com/myteam/my-native-android # timeout=10
Fetching upstream changes from https://github.com/myteam/my-native-android
 > git --version # timeout=10
using .gitcredentials to set credentials
 > git config --local credential.username email@emaple.com # timeout=10
 > git config --local credential.helper store --file=/Users/Shared/Jenkins/tmp/git8723421402276973754.credentials # timeout=10
 > git -c core.askpass=true fetch --tags --progress https://github.com/myteam/my-native-android +refs/heads/*:refs/remotes/origin/*
 > git config --local --remove-section credential # timeout=10
 > git rev-parse refs/remotes/origin/develop^{commit} # timeout=10
 > git rev-parse refs/remotes/origin/origin/develop^{commit} # timeout=10
Checking out Revision 3c5a8e26146661629d577d2e95eb346e1b473116 (refs/remotes/origin/develop)
 > git config core.sparsecheckout # timeout=10
 > git checkout -f 3c5a8e26146661629d577d2e95eb346e1b473116
 > git rev-list a5cd8ad542ba42f6bc341ecdabc24ed9f4748aa8 # timeout=10

Which is odd, I would have expected a simple git pull to work.

Getting nice release notes from git in jenkins

Reading List

GitFlow

gitflow is the definitive workflow for git. No compelling reason to use anthing else.

Unless githubflow works for you, introduction via GitHub.

More on github flow.

Useful commands

Fork & keep in sync.

For CI reasons it’s useful to have a read-only fork of a repositry which is kept in sync with its master.

Terminology

Mirroring a repo

Not cloning.

  • https://chrisdown.name/2013/07/05/setting-up-local-github-mirror-with-cgit-git-daemon.html
  • http://stackoverflow.com/questions/11370239/creating-an-official-github-mirror
  • http://stackoverflow.com/questions/15871787/automatically-mirroring-a-github-repo
  • https://github.com/beefsack/git-mirror

Password caching

On MacOS, take a look here, basicall git config --global credential.helper osxkeychain


Setup github

I’m rikwatson on GitHub & A/C Create on GitLab, also rikwatson

A nice branching method here

  • GitBox
  • gist.io Very cool
  • http://robots.thoughtbot.com/post/4747482956/streamline-your-git-workflow-with-aliases
  • https://sandofsky.com/blog/git-workflow.html

Gists

Simple command line access via gist, install via brew install gist

Gists visible on wwwroot in Dropbox. GistBox looks cook.

You can get the RAW text of a GIST via: https://gist.github.com/rikwatson/3688990/raw/

(Possibly even http).

Look at C:\Dropbox\work\chromepackaged_apps_template\00-build.py & C:\Dropbox\Public\gists

Mirroring a repository

To make an exact duplicate, you need to perform both a bare-clone and a mirror-push.

Open up the command line, and type these commands:

git clone --bare https://github.com/exampleuser/old-repository.git
# Make a bare clone of the repository

cd old-repository.git
git push --mirror https://github.com/exampleuser/new-repository.git
# Mirror-push to the new repository

cd ..
rm -rf old-repository.git
# Remove our temporary local repository

If you want to mirror a repository in another location, including getting updates from the original, you can clone a mirror and periodically push the changes.

git clone --mirror https://github.com/exampleuser/repository-to-mirror.git
# Make a bare mirrored clone of the repository

cd repository-to-mirror.git
git remote set-url --push origin https://github.com/exampleuser/mirrored
# Set the push location to your mirror

As with a bare clone, a mirrored clone includes all remote branches and tags, but all local references will be overwritten each time you fetch, so it will always be the same as the original repository. Setting the URL for pushes simplifies pushing to your mirror. To update your mirror, fetch updates and push, which could be automated by running a cron job.

git fetch -p origin
git push --mirror

$ mkdir git-cli
$ cd git-cli/
$ ls

$ echo "test" > first.txt

$ ls
first.txt

$ git status
fatal: Not a git repository (or any of the parent directories): .git

$ git init
Initialized empty Git repository in C:/_root/git-cli/.git/

$ git st
On branch master

Initial commit

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

        first.txt

nothing added to commit but untracked files present (use "git add" to track)

$ git add first.txt

$ git st
On branch master

Initial commit

Changes to be committed:
  (use "git rm --cached <file>..." to unstage)

        new file:   first.txt


$ echo "asdadasd" > first.txt

$ git status
On branch master

Initial commit

Changes to be committed:
  (use "git rm --cached <file>..." to unstage)

        new file:   first.txt

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

        modified:   first.txt


$ git diff --staged
diff --git a/first.txt b/first.txt
new file mode 100644
index 0000000..9daeafb
--- /dev/null
+++ b/first.txt
@@ -0,0 +1 @@
+test

$ git diff
diff --git a/first.txt b/first.txt
index 9daeafb..80939b6 100644
--- a/first.txt
+++ b/first.txt
@@ -1 +1 @@
-test
+asdadasd

$ git add .

$ git st
On branch master

Initial commit

Changes to be committed:
  (use "git rm --cached <file>..." to unstage)

        new file:   first.txt


$ git diff --staged
diff --git a/first.txt b/first.txt
new file mode 100644
index 0000000..80939b6
--- /dev/null
+++ b/first.txt
@@ -0,0 +1 @@
+asdadasd

$ git commit -m "Add first.txt"
[master (root-commit) 72da1cf] Add first.txt
 1 file changed, 1 insertion(+)
 create mode 100644 first.txt

$ git st
On branch master
nothing to commit, working tree clean

$ git hist
* 72da1cf 2017-01-20 | Add first.txt (HEAD -> master) [Rob Bell]

$ git st
On branch master
nothing to commit, working tree clean

$ git remote add origin https://github/robbell/git-cli

$ git push -u origin master
fatal: unable to access 'https://github/robbell/git-cli/': Couldn't resolve host 'github'

$ git remote add origin https://github.com/robbell/git-cli
fatal: remote origin already exists.

$ git remote remove origin

$ git remote add origin https://github.com/robbell/git-cli

$ git push -u origin master
Counting objects: 3, done.
Writing objects: 100% (3/3), 220 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To https://github.com/robbell/git-cli
 * [new branch]      master -> master
Branch master set up to track remote branch master from origin.

$ echo "second change" > second.txt

$ echo "second change" > first.txt

$ git st
On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        modified:   first.txt

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

        second.txt

no changes added to commit (use "git add" and/or "git commit -a")

$ git add .

$ git commit -m "Add second.txt"
[master af41b73] Add second.txt
 2 files changed, 2 insertions(+), 1 deletion(-)
 create mode 100644 second.txt

$ git st
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
  (use "git push" to publish your local commits)
nothing to commit, working tree clean

$ git hist
* af41b73 2017-01-20 | Add second.txt (HEAD -> master) [Rob Bell]
* 72da1cf 2017-01-20 | Add first.txt (origin/master) [Rob Bell]

$ git pull
Already up-to-date.

$ git push
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 264 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To https://github.com/robbell/git-cli
   72da1cf..af41b73  master -> master