Skip to content

Instantly share code, notes, and snippets.

@jlant
Last active November 28, 2016 21:48
Show Gist options
  • Save jlant/bb8118b09b8df4662ae4 to your computer and use it in GitHub Desktop.
Save jlant/bb8118b09b8df4662ae4 to your computer and use it in GitHub Desktop.
Git - list of helpful commands

Git reference

Local config settings (just do not include the --global option)

$ git config user.name "your-name"
$ git config user.email "your-email"

Delete commits back to a specific commit

$ git reset --hard <commit number>

Manage multiple github accounts

  • git remote add origin git@personal:jlant/<some-repo>.git
  • git remote add origin git@work:jlant-usgs/<some-repo>.git
  • git remote add origin git@work_gitlab:jlant/gagepy.git
$ touch readme.md
$ git init
$ git add .
$ git commit -am "first commit"
$ git remote add origin git@personal:githubPersonal/test-personal.git
$ git push origin master

Clone a repo with multiple github accounts

$ git clone git@work_gitlab:jlant/gagepy.git

Create ssh keys

$ ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
Generating public/private rsa key pair.
...
Enter passphrase
...
The key fingerprint is:
...

$ eval $(ssh-agent)
$ ssh-add ~/.ssh/id_rsa
$ clip < ~/.ssh/id_rsa.pub

Having ssh key problems?

Error message - "Agent admitted failure to sign using the key."
Re-do the following:

$ ssh-add ~/.ssh/id_rsa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment