If you ever met the following errors when trying to git or ssh after upgraded your OS to sierra:
Unable to negotiate with legacyhost: no matching host key type found. Their offer: ssh-dss
Just relax, it’s not your fault but your server’s fault. Upgrading your OS to sierra will also bump your OpenSSH from version 6.9 to 7.2. According to the document of OpenSSH 7 (http://www.openssh.com/legacy.html):
OpenSSH 7.0 and greater similarly disable the ssh-dss (DSA) public key algorithm. It too is weak and we recommend against its use. It can be re-enabled using the HostKeyAlgorithms configuration option:
ssh -oHostKeyAlgorithms=+ssh-dss user@legacyhost
or in the ~/.ssh/config file:
However, it is probably not enough. You may be prompted for password all the time but no password is correct. In that case, you can simply append another line in your ~/.ssh/config file:
That’s it! Don’t forget to restart your sshd service before retrying.
Sometimes you just need to ignore the changes of some file, for example, database configuration, you may need the following command:
git update-index --assume-unchanged <file>
To track again, use:
git update-index --no-assume-unchanged <file>
If you want to turn a folder within a Git repository into a brand new repository, and you don’t want to lose any of your Git history or changes, you can use git filter-branch command. For example,
git filter-branch --prune-empty --subdirectory-filter SUBFOLDER_NAME master
All the other files but the subfolder would be removed. Now you can add a new remote and then push it to your new location.
How to merge an existing repository into a new subdirectory of the current repository?
Here is the answer!
If the exist repo path is: /path/to/ex/repo, and you can give it a new name such as: ExRepo
If you want to import this repo to the current repository as sub-directory SubDir:
- git remote add -f ExRepo /path/to/ex/repo
- git merge -s ours –no-commit ExRepo/master
- git read-tree –prefix=SubDir/ -u ExRepo/master
- git commit -m “Merge ExRepo as our subdirectory SubDir“
It’s done! Just four lines. What do these steps mean?
- fetch the other project “ExRepo“
- prepare for the later step to record the result as a merge
- read “master” branch of ExRepo to the subdirectory “SubDir“
- record the merge result
You may commit exist changes first if you have got the error “Merge with strategy ours failed“.
One more thing, how to update SubDir after merging is simple the same. Just type:
- git pull -s subtree ExRepo master
Enjoy & Good lock!