Date created: 09/13/18 11:44:09. Last modified: 05/15/19 11:00:59



Global settings:

git config --global "James Bensley"
git config --global "[email protected]"


Adding a git remote origin:

git remote add origin ssh://[email protected]/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 [email protected]:group/project.git # 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 [email protected]:jwbensley/network_graphs.git
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


Previous page: Cisco Watch
Next page: Audio Size