mobilege / Git   Documentation   tldr

Git

  • https://docs.gitlab.com/ee/topics/git/
  • https://www.atlassian.com/git/tutorials
  • https://github.com/git-guides
  • /usr/bin/git is the path to the system-provided Git executable.
    • Apple actually maintain and ship their own fork of Git. source
  • /usr/local/bin/git symbolic link to the Git executable when installed via Homebrew
    • points to /usr/local/Cellar/git/2.34.1/bin/git
Git Branching
$ git branch testing   # Create a new local branch
$ git checkout testing # Switch to an existing local branch

$ git checkout -b iss53 # Create a new local branch & switch to it (in one step)

https://git-scm.com/book/en/v2/Git-Branching-Basic-Branching-and-Merging

Pushing
$ git push <remote> <local branch>:<remote branch>
$ git push origin serverfix  # if the local & remote branches have the same name
$ git push  # pushes current branch, if tracking set up
$ git push --all   # pushes all branches

https://git-scm.com/book/en/v2/Git-Branching-Remote-Branches

Tracking Branches
$ git checkout -b <branch> <remote>/<branch>
$ git checkout --track origin/serverfix
$ git checkout serverfix
# Branch serverfix set up to track remote branch serverfix from origin.
# Switched to a new branch 'serverfix'

https://git-scm.com/book/en/v2/Git-Branching-Remote-Branches > ‘Tracking Branches’

git remote prune origin
  • deletes refs to branches that don’t exist on the remote

Miscellaneous

Multiple GitHub accounts

$ git remote set-url origin git@<host>:rabin-joshi-cognizant/cognizant-enablement.git
# <host> should match the host alias defined in ~/.ssh/config
$ git config user.name "rabin-joshi-cognizant" # updates local 
$ git config user.email "rabin.joshi@cognizant.com" # updates local 
$ git config -l # shows all: system, global and local
SSH Config
$ code ~/.ssh/config # opens the file in VS Code

using-the-ssh-config-file https://linuxize.com/post/using-the-ssh-config-file/