Description | Command | Reference |
---|---|---|
Store credentials | git config credential.helper store |
|
Allow no comment on commit | git config --global alias.nccommit 'commit -a --allow-empty-message -m ""' |
Source |
Undo a commit | git reset HEAD~ |
|
List remotes | git remote -v |
|
Change remote | git remote set-url origin <URL> |
Reference |
Append to last commit | git commit --amend |
-
create a new repository that has the initial commit that you want
mkdir foo; cd foo; git init; ...; git commit
-
set up a remote
git remote add origin <url-of-remote> git branch --set-upstream master origin/master
-
push your new history
`git push -f``
-
delete obsolete remote branches
git push origin :deprecated-branch
git fetch origin
git reset --hard origin/master
-
Add the remote, call it "upstream":
git remote add upstream https://github.com/whoever/whatever.git
-
Fetch all the branches of that remote into remote-tracking branches, such as upstream/master:
git fetch upstream
-
Make sure that you're on your master branch:
git checkout master
-
Rewrite your master branch so that any commits of yours that aren't already in upstream/master are replayed on top of that other branch:
git rebase upstream/master
- Get
libsecret
andgnome-keyring
(seahorse
for GUI) git config --global credential.helper libsecret
- Get
gnupg
- Script:
https://raw.githubusercontent.com/git/git/master/contrib/credential/netrc/git-credential-netrc
- Arch:
/usr/share/git/credential/netrc/git-credential-netrc
- Ubuntu:
/usr/share/doc/git/contrib/credential/netrc/git-credential-netrc
- Arch:
- Create a new file (preferably
~/.netrc
):machine github.com protocol <http|https|ssh> login <username> password <password>
- Generate a new key (if there's none already):
gpg --gen-key
- Encrypt the file:
gpg -e -r <email> ~/.netrc
git config --global credential.helper "netrc -f ~/.netrc -v"
git-credentials-
prefix will be automatically prepended to formgit-credentials-netrc
- Can add
-d
for debugging - For more info,
git-credentials-netrc --help
https://github.com/git/git/tree/master/contrib/credential