I had 2 accounts in gitlab.com and I couldn’t use one rsa key to access both accounts. It seems like gitlab’s restriction.
So, I needed to create another key for the 2nd account. Let’s try.
- Generate a new key
$ ssh-keygen -t rsa -b 4096 -C "firstname.lastname@example.org"
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/myid/.ssh/id_rsa): /Users/myid/.ssh/new_rsa
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /Users/myid/.ssh/new_rsa.
Your public key has been saved in /Users/myid/.ssh/new_rsa.pub.
- Update ssh config file
$ vi ~/.ssh/config
- Add the new key created to ssh agent
$ ssh-add ~/.ssh/new_rsa
- Add or update the git repository path
$ git remote add origin git@gitlab-com-new:new_id/new_repository.git
# or if the repository already exists
$ git remote set-url origin git@gitlab-com-new:new_id/new_repository.git
- Enjoy 😛
Sometimes it’s silly when reviewing the code change from git diff command which is a simple way to see the differences between the codes from the previous and the updated and the commit contains a large css file. Actually I use less for generating css, so I don’t really need to open up and see the css file. Anyways, you can ignore any file you want from git diff. Here’s how.
You can create a .gitattributes file in the root of the repo. Inside that file, you can now exclude certain files/types from the git diff command just like the way of excluding files from .gitignore:
Git 2.0 the default behavior will be to only push the current branch checked out. The option is currently a setting called simple for option push.default.
So you can set this new (in my opinion better) default behavior right now.
$ git config --global push.default simple
and that’s it. Just in case you want to use that. The old default, that pushed everything at once just in case you want to go back was matching, instead of simple.
For a specific file use:
$ git checkout path/to/file/to/revert
For all unstaged files use:
$ git checkout -- .
Don’t forget to add ‘.’ at the end.
If you want to list all files for a specific branch, e.g. master:
$ git ls-tree -r master --name-only
-d Show only the named tree entry itself, not its children.
-r Recurse into sub-trees.
You can specify HEAD instead of master to get the list for any other branch you might be in.
If you want to get a list of all files that ever existed:
$ git log --pretty=format: --name-only --diff-filter=A | sort -