select 'drop database '||datname||';'
from pg_database
where datistemplate=false
and datname != 'postgres'
order by 1
from pg_database
where datistemplate=false
and datname != 'postgres'
order by 1
git config --global user.name "John Doe" git config --global user.email "john@example.com"
--global
to set the configuration for all projects. If git config
is used without --global
and run inside a project directory, the settings are set for the specific project.cd project/ git config core.filemode false
git config --list
cd existing-project/ git init
git clone https://github.com/user/repository.git
git clone https://github.com/user/repository.git .
git help clone
cd repository/ git pull origin master
git fetch
git remote -v
git remote set-url origin http//github.com/repo.git
git remote add remote-name https://github.com/user/repo.git
git diff
git diff --cached
git diff origin/master
origin/master
is one local branch, a shorthand for refs/remotes/origin/master
, which is the full name of the remote-tracking branch.git diff COMMIT1_ID COMMIT2_ID
git diff --name-only COMMIT1_ID COMMIT2_ID
git diff-tree --no-commit-id --name-only -r COMMIT_ID
git show --pretty="format:" --name-only COMMIT_ID
git diff --cached origin/master
git show COMMIT_ID
git status
git add changed_file.txt git add folder-with-changed-files/ git commit -m "Commiting changes"
git rm removeme.txt tmp/crap.txt git mv file_oldname.txt file_newname.txt git commit -m "deleting 2 files, renaming 1"
git commit --amend -m "New commit message"
git push origin master
git log
git log -2
git log -p -2
git log --pretty=oneline
git revert dd61ab21 git push origin master
# reset the index to the desired tree git reset 56e05fced # move the branch pointer back to the previous HEAD git reset --soft HEAD@{1} git commit -m "Revert to 56e05fced" # Update working copy to reflect the new commit git reset --hard
git reset --soft HEAD~1
git reset --hard HEAD~1
git reset --mixed HEAD~1
git reset origin/master
git fetch origin git reset --hard origin/master
git branch
git branch -a
git diff > patch-issue-1.patch
git add newfile git diff --staged > patch-issue-2.patch
git add newfile git diff HEAD > patch-issue-2.patch
git format-patch COMMIT_ID
git format-patch HEAD~2
git format-patch origin/master
git format-patch --binary --full-index origin/master
git apply -v patch-name.patch
format-patch
git am patch1.patch
git tag 7.x-1.3
git push origin 7.x-1.3
git checkout master git branch new-branch-name
master
is the starting point for the new branch. Note that with these 2 commands we don't move to the new branch, as we are still in master and we would need to run git checkout new-branch-name
. The same can be achieved using one single command: git checkout -b new-branch-name
git branch branchname
git branch branchname HEAD~1
git checkout -b branchname
git checkout new-branch-name
git cherry -v master
master
is the branch you want to compare)git checkout master git merge branch-name
branch-name
to master
.git merge branch-name --no-commit --no-ff
git diff branch-name
git diff branch-name path/to/file
git branch -d new-branch-name
git push origin new-branch-name
git fetch origin
git rev-parse --show-toplevel
git rm $(git ls-files --deleted)
git clean -f
git clean -f -d
git clean -n -f -d
git ls-files --deleted -z | xargs -0 git rm
git reset HEAD file.txt
git describe --tags `git rev-list --tags --max-count=1`
screen for((i=1;i<=10000;i+=1)); do sleep 30 && git pull; done
history | grep git
grep '^git' /root/.bash_history
git for-each-ref --sort=-committerdate refs/heads/ | head
cd .. tar cJf project.tar.xz project/ --exclude-vcs
git diff --name-only | xargs tar -cf project.tar -T -
grep -H -r "<<<" * grep -H -r ">>>" * grep -H -r '^=======$' *
patch -p1 < file.patch