This is an old revision of the document!
Git Cheat Sheet
Merge Unrelated Histories
Usually happens when just create new repo in Bitbucket and auto create .gitignore. It will conflict with our local repo which hasn't been registered in any external repo.
The error is resolved by toggling the allow-unrelated-histories switch. After a git pull or git merge command, run the following command:
git pull http://bitbucket.org/etcetc master --allow-unrelated-histories
Resolving Conflict
to open UI tool, git mergetool
Setup SSH Connection to Github
check SSH key that you already have → see ~/.ssh see if there's one of the following files:
id_rsa.pub id_ecdsa.pub id_ed25519.pub
if exists, then you already have some SSH keys.
Generate new key use the following command :
ssh-keygen -t ed25519 -C “your_email@example.com”
to connect to github.com, it is highly recommended to use the ed25519 key type. put your email as key's comment (the “-C” option) to remind you the purpose/context of this key
When you're prompted to “Enter a file in which to save the key,” use a descriptive name to easily identify which key related to what identity. For example : if you use “jim.merari@gmail.com” as the key comment, you might use “id_ed25519_jimmerarigmail” as the filename.
When prompted to fill the passphrase, you can choose to use password or leave it blank.
So this key will correspond to that specific email. ssh-keygen will generate two files : the private and the public key. the one with “.pub” prefix is the public key.
go to github.com, login as usual, click the Settings under the profile menu. Then open the SSH/GPG menu. The page will list all the keys that have associated them with your account. To add new key, - click New Key - fill the form with descriptive name. specify what device/gadget/clients you intend to use with this key - copy the content of the “.pub” file to the form - click the button
After the new key listed, then you can push/fetch from github with the command : git push ssh:git@github.com:jmerari/some-repo.git git push ssh:git@bitbucket.org:jmerari/some-repo.git
If you generate key without passphrase, this git command won't ask for password. But if you generated the key with passphrase, you will need to type it here. Remember, this is the password for the key, not the github.com password.
https://docs.github.com/en/authentication/connecting-to-github-with-ssh/about-ssh https://support.atlassian.com/bitbucket-cloud/docs/set-up-an-ssh-key/