Date created: 09/13/18 11:44:09. Last modified: 03/23/20 16:05:56
Git
Global settings:
git config --global user.name "James Bensley"
git config --global user.email "james.bensley@email.com"
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 user@somesite.com:group/project.git # Using git
git remote add --track master origin http://github.com/group/project.git # Using HTTP
Replace the existing remote origin:
git remote set-url origin https://github.com/username/repo
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@github.com:jwbensley/network_graphs.git
git pull origin master
git reset --hard HEAD
git add *
git commit -m "commit to github.com"
git push origin master
Clone a specific branch:
git clone -b dev https://github.com/jwbensley/IP-Hashing.git
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