🌿Git
Initialisation/Starting
Init a repository
git init
Adding a Git remote
# add using ssh
git remote add origin [email protected]:path/to/repo.git
# add using https
git remote add origin https://github.com/paht/to/repo.git
Change URL of Git remote
git remote set-url origin [email protected]:/path/to/repo.git
Clone a repository
# this will clone into a new directory named 'repo'
git clone github.com/path/to/repo.git
# this will clone into the current directory
git clone github.com/path/to/repo.git .
Development
Adding an item to the Git repository
# add everything in the current directory
git add .
# add a specific file
git add ./path/to/file
Remove an item from the Git cache
# remove a file
git rm --cache ./path/to/file
# remove a directory
git rm -r --cache ./path/to/directory
Creating a new branch
git checkout -b branch-name
Rebasing from master
git checkout target-branch && git rebase master
Squashing commits
# squash ${N_COMMITS} commits into one commit
git rebase -i HEAD~${N_COMMITS};
Release
Listing all Git tags
git tag --list
Adding Git tag to current commit
git tag v1.2.3
Last updated
Was this helpful?