-
Notifications
You must be signed in to change notification settings - Fork 0
Git cheat sheet
git config --global credential.helper cache
git config --global credential.helper "cache --timeout=3600"
git remote set-url origin [email protected]:<username>/<repo>.git
(from here):
git checkout -b local_branch remotes/origin/remote_branch
Attach local repo to remote (from here):
git remote add origin <remote_repo_url>
git push --all origin
If you want to set all of your branches to automatically use this remote repo when you use git pull, add --set-upstream to the push:
git push --all --set-upstream origin
Create file in .git/hooks/post-commit
that contains the following:
#!/bin/sh
git push
$ git commit ... (1)
$ git reset --soft 'HEAD^' (2)
$ edit (3)
$ git add .... (4)
$ git commit -c ORIG_HEAD (5)
This is what you want to undo
This is most often done when you remembered what you just committed is incomplete, or you misspelled your commit message, or both. Leaves working tree as it was before "reset". (The quotes may or may not be required in your shell)
Make corrections to working tree files.
Stage changes for commit.
"reset" copies the old head to .git/ORIG_HEAD; redo the commit by starting with its log message. If you do not need to edit the message further, you can give -C option instead.
git clone <git repository A url>
cd <git repository A directory>
git remote rm origin
git filter-branch --subdirectory-filter <directory 1> -- --all
mkdir <directory 1>
mv * <directory 1>
git add .
git commit
git clone <git repository B url>
cd <git repository B directory>
git remote add repo-A-branch <git repository A directory>
git pull repo-A-branch master
git remote rm repo-A-branch