Werner Digital

Technology

Git Guide III - Advanced

Exploring git

Contents

Overview

gitk

The graphical viewer gitk is installed by default along with the standard command line.

Once familiar with it, it is often useful to make changes with the command line and refresh the view to see if it changes as expected.

There are other gui git clients, a great list is kept on the git site GUI page

Advanced Remotes

Multiple Remotes

There are times when you need to keep track of multiple clones.

  • git remote add another /path/to/another_repo.git This adds a label that can be used with push/pull/fetch like so

  • git pull another different_branch which merges the branch into your current branch

  • git fetch another pulls the other repo branches into your references, but does not write anything into the working directory. Use this if you want to diff or checkout the copy without touching your current.

Git Remotes

  • git remote add
  • git remote rm
  • git push origin main

Multiple accounts

Using ssh keys

on Unix

  • generate ssh-keygen -f ~/.ssh/id_rsa_my_company_account
  • list ls ~/.ssh/id_rsa_my_company_account*
  • public cat ~/.ssh/id_rsa_my_company_account.pub

On ~/.ssh/config

Host my_company_account_github.com
  Hostname github.com
  IdentityFile ~/.ssh/id_rsa_my_company_account

Then use the fake my_company_account_github.com

  • git clone git@my_company_account_github.com:company/repo.git or set it
  • git remote set-url origin git@my_company_account_github.com:company/repo.git or edit it in .git/config
[remote "origin"]
        url = ssh://git@github.com/autonomoose/wbench.git
        fetch = +refs/heads/*:refs/remotes/origin/*

to determine which credentials being used

ssh -T git@my_company_account_github.com
ssh -v git@my_company_account_github.com

Github Automation

Submodules or Subtrees?

https://blog.developer.atlassian.com/the-power-of-git-subtree

Workflows

Stash or temp commit?

  • git stash

  • git stash

  • git stash pop

  • git stash list

  • git stash apply

  • git stash drop

The case against stash:

  • doesn't pick up untracked files

work-in-progress

  • git add .
  • git commit -m "(WIP) work in progress"

to restore

  • git reset HEAD^

Large File Storage

Mirror