Date created: 09/13/18 11:44:09. Last modified: 03/23/20 16:05:56



Global settings:

git config --global "James Bensley"
git config --global ""


Adding a git remote origin:

git remote add origin ssh://login@IP/path/to/repository # Using SSH
git remote add origin http://IP/path/to/repository # Using HTTP
git push -u origin master


Add a specific branch (e.g. master) from a remote origin:

git remote add --track master origin # Using git
git remote add --track master origin # Using HTTP


Replace the existing remote origin:

git remote set-url origin


Commit files in an existing directory to an existing git repo (as long as the local files don't overlap with the remote repo):

git init
git remote add origin
git pull origin master
git reset --hard HEAD
git add *
git commit -m "commit to"
git push origin master


Clone a specific branch:

git clone -b dev


Ammend a git commit:

git commit --amend
# follow prompts to change the commit message


Remove .DS_Store files from repos on a Mac:

echo .DS_Store >> .gitignore  # Add them to the git infore before commiting
git add .gitignore
git commit -m 'gitignore .DS_Store'

or set up a global ignore:

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


Handy git commands:

alias gitgraph="git log --all --decorate --oneline --graph"

Previous page: Cisco Watch
Next page: Audio Size