Skip to content

Instantly share code, notes, and snippets.

@prograhammer
Last active November 4, 2024 02:58
Show Gist options
  • Save prograhammer/81cac393bf599e69f825 to your computer and use it in GitHub Desktop.
Save prograhammer/81cac393bf599e69f825 to your computer and use it in GitHub Desktop.

Revisions

  1. prograhammer revised this gist Dec 17, 2017. 1 changed file with 0 additions and 3 deletions.
    3 changes: 0 additions & 3 deletions git-cheat-sheet.md
    Original file line number Diff line number Diff line change
    @@ -100,9 +100,6 @@ Easy squash (let's squash last 3 commits)
    $ git log # to see list of recent commits, see how far you want to squash back to (3 for example)
    $ git reset --soft HEAD~3 &&
    $ git commit -m "write a new commit message from scratch for all the commits you just squashed"

    *If you want a concatenation of the commits:
    See this [stackoverflow answer](https://stackoverflow.com/a/5201642/1110941) for more info.*

    "Interactive rebase", squash a branch, rebase, push to github

  2. prograhammer revised this gist Dec 17, 2017. 1 changed file with 0 additions and 2 deletions.
    2 changes: 0 additions & 2 deletions git-cheat-sheet.md
    Original file line number Diff line number Diff line change
    @@ -97,8 +97,6 @@ Clone fork (a fork already on your github) & setup upstream (a remote to the ver

    Easy squash (let's squash last 3 commits)

    If you want to write the new commit message from scratch, this suffices:

    $ git log # to see list of recent commits, see how far you want to squash back to (3 for example)
    $ git reset --soft HEAD~3 &&
    $ git commit -m "write a new commit message from scratch for all the commits you just squashed"
  3. prograhammer revised this gist Dec 17, 2017. 1 changed file with 3 additions and 4 deletions.
    7 changes: 3 additions & 4 deletions git-cheat-sheet.md
    Original file line number Diff line number Diff line change
    @@ -97,15 +97,14 @@ Clone fork (a fork already on your github) & setup upstream (a remote to the ver

    Easy squash (let's squash last 3 commits)

    You can do this fairly easily without git rebase or git merge --squash. In this example, we'll squash the last 3 commits.

    If you want to write the new commit message from scratch, this suffices:

    $ git log # to see list of recent commits, see how far you want to squash back to (3 for example)
    $ git reset --soft HEAD~3 &&
    $ git commit -m "write a new commit message from scratch for all the commits you just squashed"

    If you want a concatenation of the commits:
    See this [stackoverflow answer](https://stackoverflow.com/a/5201642/1110941) for more info.
    *If you want a concatenation of the commits:
    See this [stackoverflow answer](https://stackoverflow.com/a/5201642/1110941) for more info.*

    "Interactive rebase", squash a branch, rebase, push to github

  4. prograhammer revised this gist Dec 17, 2017. 1 changed file with 18 additions and 6 deletions.
    24 changes: 18 additions & 6 deletions git-cheat-sheet.md
    Original file line number Diff line number Diff line change
    @@ -77,13 +77,13 @@ Delete a tag

    #### Common Git Scenarios

    Push some code changes up to github repo
    Push some code changes up to github repo forcing an overwrite of whatever is there

    # git init
    # git remote add origin https://github.com/your-username/your-repo.git
    # git add -A
    # git commit -m "updated my package"
    # git push --force origin master
    $ git init
    $ git remote add origin https://github.com/your-username/your-repo.git
    $ git add -A
    $ git commit -m "updated my package"
    $ git push origin master # use --force to overwrite existing on remote github

    Clone fork (a fork already on your github) & setup upstream (a remote to the very original you cloned from)

    @@ -95,6 +95,18 @@ Clone fork (a fork already on your github) & setup upstream (a remote to the ver
    $ git remote -v
    $ git fetch upstream

    Easy squash (let's squash last 3 commits)

    You can do this fairly easily without git rebase or git merge --squash. In this example, we'll squash the last 3 commits.

    If you want to write the new commit message from scratch, this suffices:

    $ git log # to see list of recent commits, see how far you want to squash back to (3 for example)
    $ git reset --soft HEAD~3 &&

    If you want a concatenation of the commits:
    See this [stackoverflow answer](https://stackoverflow.com/a/5201642/1110941) for more info.

    "Interactive rebase", squash a branch, rebase, push to github

    - First let's create the branch
  5. prograhammer revised this gist Jan 5, 2016. 1 changed file with 0 additions and 8 deletions.
    8 changes: 0 additions & 8 deletions git-cheat-sheet.md
    Original file line number Diff line number Diff line change
    @@ -172,11 +172,3 @@ Setup Git to use SSH key (perhaps for Bitbucket or Github)
    # ssh-add -l
    [2048 7a:9c:b2:9c:8e:4e:f4:af:de:70:77:b9:52:fd:44:97 /root/.ssh/somekey (RSA)]
    #### Bitbucket
    Add origin, push up code
    cd /path/to/my/repo
    git remote add origin [email protected]:davidkimbia/sandbox.git
    git push -u origin --all # pushes up the repo and its refs for the first time
    git push -u origin --tags # pushes up any tags
  6. prograhammer revised this gist Jan 5, 2016. 1 changed file with 10 additions and 1 deletion.
    11 changes: 10 additions & 1 deletion git-cheat-sheet.md
    Original file line number Diff line number Diff line change
    @@ -170,4 +170,13 @@ Setup Git to use SSH key (perhaps for Bitbucket or Github)
    // Use the ssh-add command to list the keys that the agent is managing.
    # ssh-add -l
    [2048 7a:9c:b2:9c:8e:4e:f4:af:de:70:77:b9:52:fd:44:97 /root/.ssh/somekey (RSA)]
    [2048 7a:9c:b2:9c:8e:4e:f4:af:de:70:77:b9:52:fd:44:97 /root/.ssh/somekey (RSA)]
    #### Bitbucket
    Add origin, push up code
    cd /path/to/my/repo
    git remote add origin [email protected]:davidkimbia/sandbox.git
    git push -u origin --all # pushes up the repo and its refs for the first time
    git push -u origin --tags # pushes up any tags
  7. prograhammer revised this gist Nov 8, 2015. 1 changed file with 6 additions and 2 deletions.
    8 changes: 6 additions & 2 deletions git-cheat-sheet.md
    Original file line number Diff line number Diff line change
    @@ -67,9 +67,13 @@ Rebase the current branch off of some other branch (most of the time "some-other
    Create and push a tag up

    # git tag
    # git tag -a v0.12.1 -m "something here about it"
    # git push origin v0.12.1
    # git tag -a v1.0.1 -m "something here about it"
    # git push origin v1.0.1

    Delete a tag

    # git tag -d v1.0.1
    # git push origin :refs/tags/v1.0.1

    #### Common Git Scenarios

  8. prograhammer revised this gist Jul 27, 2015. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions git-cheat-sheet.md
    Original file line number Diff line number Diff line change
    @@ -64,6 +64,12 @@ Rebase the current branch off of some other branch (most of the time "some-other
    # git branch -l // shows you are currently on some-branch
    # git rebase some-other-branch // now rebase off of some-other-branch

    Create and push a tag up

    # git tag
    # git tag -a v0.12.1 -m "something here about it"
    # git push origin v0.12.1


    #### Common Git Scenarios

  9. prograhammer revised this gist Apr 29, 2015. 1 changed file with 10 additions and 0 deletions.
    10 changes: 10 additions & 0 deletions git-cheat-sheet.md
    Original file line number Diff line number Diff line change
    @@ -88,34 +88,44 @@ Clone fork (a fork already on your github) & setup upstream (a remote to the ver
    "Interactive rebase", squash a branch, rebase, push to github

    - First let's create the branch

    ```
    $ git checkout -b my-branch
    $ git add -A
    $ git commit -m "added some new feature"
    $ git merge-base my-branch master
    ```
    - That command will return a commit hash. Use that commit hash in constructing this next command:
    ```
    $ git rebase --interactive ${HASH}
    ```
    - Note that you should replace ${HASH} with the actual commit hash from the previous command. For example, if your merge base is abc123, you would run $ git rebase --interactive abc123. Your text editor will open with a file that lists all the commits in your branch, and in front of each commit is the word "pick". It looks something like this:
    ```
    pick 1fc6c95 do something
    pick 6b2481b do something else
    pick dd1475d changed some things
    pick c619268 fixing typos
    ```
    - For every line except the first, you want to replace the word "pick" with the word "squash". It should end up looking like this:
    ```
    pick 1fc6c95 do something
    squash 6b2481b do something else
    squash dd1475d changed some things
    squash c619268 fixing typos
    ```
    - Save and close the file, and a moment later a new file should pop up in your editor, combining all the commit messages of all the commits. Reword this commit message as you want, and then save and close that file as well. This commit message will be the commit message for the one, big commit that you are squashing all of your larger commits into. Once you've saved and closed that file, your commits have been squashed together, and you're done with this step!
    ```
    $ git rebase upstream/master
    ```
    Setup Git to use SSH key (perhaps for Bitbucket or Github)
    // Go to ssh directory (or create it if it doesn't exist)
  10. prograhammer revised this gist Apr 29, 2015. 1 changed file with 10 additions and 10 deletions.
    20 changes: 10 additions & 10 deletions git-cheat-sheet.md
    Original file line number Diff line number Diff line change
    @@ -88,34 +88,34 @@ Clone fork (a fork already on your github) & setup upstream (a remote to the ver
    "Interactive rebase", squash a branch, rebase, push to github

    - First let's create the branch
    ```
    ```
    $ git checkout -b my-branch
    $ git add -A
    $ git commit -m "added some new feature"
    $ git merge-base my-branch master
    ```
    ```
    - That command will return a commit hash. Use that commit hash in constructing this next command:

    ```
    $ git rebase --interactive ${HASH}

    ```
    - Note that you should replace ${HASH} with the actual commit hash from the previous command. For example, if your merge base is abc123, you would run $ git rebase --interactive abc123. Your text editor will open with a file that lists all the commits in your branch, and in front of each commit is the word "pick". It looks something like this:

    ```
    pick 1fc6c95 do something
    pick 6b2481b do something else
    pick dd1475d changed some things
    pick c619268 fixing typos

    ```
    - For every line except the first, you want to replace the word "pick" with the word "squash". It should end up looking like this:

    ```
    pick 1fc6c95 do something
    squash 6b2481b do something else
    squash dd1475d changed some things
    squash c619268 fixing typos

    ```
    - Save and close the file, and a moment later a new file should pop up in your editor, combining all the commit messages of all the commits. Reword this commit message as you want, and then save and close that file as well. This commit message will be the commit message for the one, big commit that you are squashing all of your larger commits into. Once you've saved and closed that file, your commits have been squashed together, and you're done with this step!

    ```
    $ git rebase upstream/master

    ```
    Setup Git to use SSH key (perhaps for Bitbucket or Github)
    // Go to ssh directory (or create it if it doesn't exist)
  11. prograhammer revised this gist Apr 29, 2015. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions git-cheat-sheet.md
    Original file line number Diff line number Diff line change
    @@ -88,12 +88,12 @@ Clone fork (a fork already on your github) & setup upstream (a remote to the ver
    "Interactive rebase", squash a branch, rebase, push to github

    - First let's create the branch

    ```
    $ git checkout -b my-branch
    $ git add -A
    $ git commit -m "added some new feature"
    $ git merge-base my-branch master

    ```
    - That command will return a commit hash. Use that commit hash in constructing this next command:

    $ git rebase --interactive ${HASH}
  12. prograhammer revised this gist Apr 29, 2015. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions git-cheat-sheet.md
    Original file line number Diff line number Diff line change
    @@ -87,8 +87,7 @@ Clone fork (a fork already on your github) & setup upstream (a remote to the ver

    "Interactive rebase", squash a branch, rebase, push to github

    - First let's create the branch...

    - First let's create the branch

    $ git checkout -b my-branch
    $ git add -A
  13. prograhammer revised this gist Apr 29, 2015. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion git-cheat-sheet.md
    Original file line number Diff line number Diff line change
    @@ -88,7 +88,8 @@ Clone fork (a fork already on your github) & setup upstream (a remote to the ver
    "Interactive rebase", squash a branch, rebase, push to github

    - First let's create the branch...



    $ git checkout -b my-branch
    $ git add -A
    $ git commit -m "added some new feature"
  14. prograhammer revised this gist Apr 29, 2015. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions git-cheat-sheet.md
    Original file line number Diff line number Diff line change
    @@ -89,10 +89,10 @@ Clone fork (a fork already on your github) & setup upstream (a remote to the ver

    - First let's create the branch...

    $ git checkout -b my-branch
    $ git add -A
    $ git commit -m "added some new feature"
    $ git merge-base my-branch master
    $ git checkout -b my-branch
    $ git add -A
    $ git commit -m "added some new feature"
    $ git merge-base my-branch master

    - That command will return a commit hash. Use that commit hash in constructing this next command:

  15. prograhammer revised this gist Apr 29, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion git-cheat-sheet.md
    Original file line number Diff line number Diff line change
    @@ -88,7 +88,7 @@ Clone fork (a fork already on your github) & setup upstream (a remote to the ver
    "Interactive rebase", squash a branch, rebase, push to github

    - First let's create the branch...

    $ git checkout -b my-branch
    $ git add -A
    $ git commit -m "added some new feature"
  16. prograhammer revised this gist Apr 29, 2015. 1 changed file with 1 addition and 3 deletions.
    4 changes: 1 addition & 3 deletions git-cheat-sheet.md
    Original file line number Diff line number Diff line change
    @@ -88,12 +88,10 @@ Clone fork (a fork already on your github) & setup upstream (a remote to the ver
    "Interactive rebase", squash a branch, rebase, push to github

    - First let's create the branch...

    $ git checkout -b my-branch

    $ git add -A
    $ git commit -m "added some new feature"

    $ git merge-base my-branch master

    - That command will return a commit hash. Use that commit hash in constructing this next command:
  17. prograhammer revised this gist Apr 29, 2015. 1 changed file with 43 additions and 0 deletions.
    43 changes: 43 additions & 0 deletions git-cheat-sheet.md
    Original file line number Diff line number Diff line change
    @@ -75,6 +75,49 @@ Push some code changes up to github repo
    # git commit -m "updated my package"
    # git push --force origin master

    Clone fork (a fork already on your github) & setup upstream (a remote to the very original you cloned from)

    $ git config --global user.name "Your Name"
    $ git config --global user.email "[email protected]"
    $ git clone https://github.com/your-username/your-forked-package.git
    $ cd your-forked-package
    $ git remote add upstream https://github.com/authors-username/original-official-package.git
    $ git remote -v
    $ git fetch upstream

    "Interactive rebase", squash a branch, rebase, push to github

    - First let's create the branch...

    $ git checkout -b my-branch

    $ git add -A
    $ git commit -m "added some new feature"

    $ git merge-base my-branch master

    - That command will return a commit hash. Use that commit hash in constructing this next command:

    $ git rebase --interactive ${HASH}

    - Note that you should replace ${HASH} with the actual commit hash from the previous command. For example, if your merge base is abc123, you would run $ git rebase --interactive abc123. Your text editor will open with a file that lists all the commits in your branch, and in front of each commit is the word "pick". It looks something like this:

    pick 1fc6c95 do something
    pick 6b2481b do something else
    pick dd1475d changed some things
    pick c619268 fixing typos

    - For every line except the first, you want to replace the word "pick" with the word "squash". It should end up looking like this:

    pick 1fc6c95 do something
    squash 6b2481b do something else
    squash dd1475d changed some things
    squash c619268 fixing typos

    - Save and close the file, and a moment later a new file should pop up in your editor, combining all the commit messages of all the commits. Reword this commit message as you want, and then save and close that file as well. This commit message will be the commit message for the one, big commit that you are squashing all of your larger commits into. Once you've saved and closed that file, your commits have been squashed together, and you're done with this step!

    $ git rebase upstream/master

    Setup Git to use SSH key (perhaps for Bitbucket or Github)

    // Go to ssh directory (or create it if it doesn't exist)
  18. prograhammer revised this gist Nov 5, 2014. 1 changed file with 8 additions and 0 deletions.
    8 changes: 8 additions & 0 deletions git-cheat-sheet.md
    Original file line number Diff line number Diff line change
    @@ -51,6 +51,14 @@ Switch to a branch

    # git checkout your-branch-here

    Delete a branch

    # git checkout other_than_branch_to_be_deleted
    // Deleting local branch
    # git branch -D branch_to_be_deleted
    // Deleting remote branch
    # git push origin --delete branch_to_be_deleted

    Rebase the current branch off of some other branch (most of the time "some-other-branch" will be "master")

    # git branch -l // shows you are currently on some-branch
  19. prograhammer revised this gist Aug 1, 2014. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions git-cheat-sheet.md
    Original file line number Diff line number Diff line change
    @@ -30,6 +30,7 @@ Force push "master" branch to remote "origin" forcing the remote to accept your
    # git push --force origin master

    Force pull and reset all files to match origin. (Won't mess with files in .gitignore)

    # git fetch --all
    # git reset --hard origin/master

  20. prograhammer revised this gist Jul 22, 2014. 1 changed file with 41 additions and 37 deletions.
    78 changes: 41 additions & 37 deletions git-cheat-sheet.md
    Original file line number Diff line number Diff line change
    @@ -3,97 +3,101 @@
    #### Single Git Commands
    Initialize a git repo in the current directory

    git init
    # git init

    Add a remote called "origin"

    git remote add origin https://github.com/your-username-here/your-repo-here.git
    # git remote add origin https://github.com/your-username-here/your-repo-here.git

    Add all untracked changed files to staging, ready to be committed

    git add -A
    # git add -A

    Commit with a message

    git commit -m "some message here"
    # git commit -m "some message here"

    Push from local branch "master" up to remote branch "origin"

    git push origin master
    # git push origin master

    Pull from remote branch "origin" down to local branch "master"

    git pull origin master
    # git pull origin master

    Force push "master" branch to remote "origin" forcing the remote to accept your changes

    git push --force origin master
    # git push --force origin master

    Force pull and reset all files to match origin. (Won't mess with files in .gitignore)
    # git fetch --all
    # git reset --hard origin/master

    Removes untracked files (not those ignored). Such as those .orig files that are left after resolving conflicts

    git clean -f -n // do this command first, with "n" flag to see what would be removed
    git clean -f // this command actually removes the files
    # git clean -f -n // do this command first, with "n" flag to see what would be removed
    # git clean -f // this command actually removes the files

    View remotes

    git remote -v
    # git remote -v

    View current branch you are on

    git branch -l
    # git branch -l

    Switch to a branch

    git checkout your-branch-here
    # git checkout your-branch-here

    Rebase the current branch off of some other branch (most of the time "some-other-branch" will be "master")

    git branch -l // shows you are currently on some-branch
    git rebase some-other-branch // now rebase off of some-other-branch
    # git branch -l // shows you are currently on some-branch
    # git rebase some-other-branch // now rebase off of some-other-branch


    #### Common Git Scenarios

    Push some code changes up to github repo

    git init
    git remote add origin https://github.com/your-username/your-repo.git
    git add -A
    git commit -m "updated my package"
    git push --force origin master
    # git init
    # git remote add origin https://github.com/your-username/your-repo.git
    # git add -A
    # git commit -m "updated my package"
    # git push --force origin master

    Setup Git to use SSH key (perhaps for Bitbucket or Github)

    # go to ssh directory (or create it if it doesn't exist)
    cd ~/.ssh
    // Go to ssh directory (or create it if it doesn't exist)
    # cd ~/.ssh

    # Generate SSH key
    ssh-keygen -t rsa -C "enter some random label here"
    // Generate SSH key
    # ssh-keygen -t rsa -C "enter some random label here"

    # Prompt "Enter file in which to save the key (/root/.ssh/somekey):"
    // Prompt "Enter file in which to save the key (/root/.ssh/somekey):"
    [Enter your key name. In this case we call it "somekey"]

    # Prompt "Enter passphrase (empty for no passphrase):"
    // Prompt "Enter passphrase (empty for no passphrase):"
    [Enter a passphrase]

    # See your public ssh key
    cat ~/.ssh/somekey.pub
    // See your public ssh key
    # cat ~/.ssh/somekey.pub

    # somekey.pub is your public key
    # somekey is your private key
    // somekey.pub is your public key
    // somekey is your private key

    # Enter this command to see if the agent is running
    ps -e | grep [s]sh-agent
    // Enter this command to see if the agent is running
    # ps -e | grep [s]sh-agent
    [9060 ?? 0:00.28 /usr/bin/ssh-agent -l]

    # If the agent isn't running, start it manually with the following command:
    ssh-agent /bin/bash
    // If the agent isn't running, start it manually with the following command:
    # ssh-agent /bin/bash

    # Load your new identity into the ssh-agent management program using the ssh-add command.
    ssh-add ~/.ssh/somekey
    // Load your new identity into the ssh-agent management program using the ssh-add command.
    # ssh-add ~/.ssh/somekey
    [Enter passphrase for /root/.ssh/id_rsa:
    Identity added: /root/.ssh/somekey]

    # Use the ssh-add command to list the keys that the agent is managing.
    ssh-add -l
    // Use the ssh-add command to list the keys that the agent is managing.
    # ssh-add -l
    [2048 7a:9c:b2:9c:8e:4e:f4:af:de:70:77:b9:52:fd:44:97 /root/.ssh/somekey (RSA)]
  21. prograhammer revised this gist Jul 8, 2014. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions git-cheat-sheet.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    ## Git Cheat Sheet

    ##### Single Git Commands
    #### Single Git Commands
    Initialize a git repo in the current directory

    git init
    @@ -52,7 +52,7 @@ Rebase the current branch off of some other branch (most of the time "some-other
    git rebase some-other-branch // now rebase off of some-other-branch


    ### Common Git Scenarios
    #### Common Git Scenarios

    Push some code changes up to github repo

  22. prograhammer revised this gist Jul 8, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion git-cheat-sheet.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    Git Cheat Sheet
    ## Git Cheat Sheet

    ##### Single Git Commands
    Initialize a git repo in the current directory
  23. prograhammer revised this gist Jul 8, 2014. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions git-cheat-sheet.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    ### Single Git Commands

    Git Cheat Sheet

    ##### Single Git Commands
    Initialize a git repo in the current directory

    git init
  24. prograhammer revised this gist Jul 3, 2014. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions git-cheat-sheet.md
    Original file line number Diff line number Diff line change
    @@ -91,8 +91,8 @@ Setup Git to use SSH key (perhaps for Bitbucket or Github)

    # Load your new identity into the ssh-agent management program using the ssh-add command.
    ssh-add ~/.ssh/somekey
    [Enter passphrase for ~/.ssh/id_rsa:
    Identity added: ~/.ssh/somekey]
    [Enter passphrase for /root/.ssh/id_rsa:
    Identity added: /root/.ssh/somekey]

    # Use the ssh-add command to list the keys that the agent is managing.
    ssh-add -l
  25. prograhammer revised this gist Jul 3, 2014. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions git-cheat-sheet.md
    Original file line number Diff line number Diff line change
    @@ -62,15 +62,15 @@ Push some code changes up to github repo
    git commit -m "updated my package"
    git push --force origin master

    Setup Git to use SSH key
    Setup Git to use SSH key (perhaps for Bitbucket or Github)

    # go to ssh directory (or create it if it doesn't exist)
    cd ~/.ssh

    # Generate SSH key
    ssh-keygen -t rsa -C "enter some random label here"

    # Prompt "Enter file in which to save the key (/c/Users/you/.ssh/id_rsa):"
    # Prompt "Enter file in which to save the key (/root/.ssh/somekey):"
    [Enter your key name. In this case we call it "somekey"]

    # Prompt "Enter passphrase (empty for no passphrase):"
  26. prograhammer revised this gist Jul 3, 2014. 1 changed file with 16 additions and 0 deletions.
    16 changes: 16 additions & 0 deletions git-cheat-sheet.md
    Original file line number Diff line number Diff line change
    @@ -81,3 +81,19 @@ Setup Git to use SSH key

    # somekey.pub is your public key
    # somekey is your private key

    # Enter this command to see if the agent is running
    ps -e | grep [s]sh-agent
    [9060 ?? 0:00.28 /usr/bin/ssh-agent -l]

    # If the agent isn't running, start it manually with the following command:
    ssh-agent /bin/bash

    # Load your new identity into the ssh-agent management program using the ssh-add command.
    ssh-add ~/.ssh/somekey
    [Enter passphrase for ~/.ssh/id_rsa:
    Identity added: ~/.ssh/somekey]

    # Use the ssh-add command to list the keys that the agent is managing.
    ssh-add -l
    [2048 7a:9c:b2:9c:8e:4e:f4:af:de:70:77:b9:52:fd:44:97 /root/.ssh/somekey (RSA)]
  27. prograhammer revised this gist Jul 3, 2014. 1 changed file with 19 additions and 0 deletions.
    19 changes: 19 additions & 0 deletions git-cheat-sheet.md
    Original file line number Diff line number Diff line change
    @@ -62,3 +62,22 @@ Push some code changes up to github repo
    git commit -m "updated my package"
    git push --force origin master

    Setup Git to use SSH key

    # go to ssh directory (or create it if it doesn't exist)
    cd ~/.ssh

    # Generate SSH key
    ssh-keygen -t rsa -C "enter some random label here"

    # Prompt "Enter file in which to save the key (/c/Users/you/.ssh/id_rsa):"
    [Enter your key name. In this case we call it "somekey"]

    # Prompt "Enter passphrase (empty for no passphrase):"
    [Enter a passphrase]

    # See your public ssh key
    cat ~/.ssh/somekey.pub

    # somekey.pub is your public key
    # somekey is your private key
  28. prograhammer revised this gist Jul 3, 2014. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions git-cheat-sheet.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    ### Single Commands
    ### Single Git Commands


    Initialize a git repo in the current directory
    @@ -52,7 +52,7 @@ Rebase the current branch off of some other branch (most of the time "some-other
    git rebase some-other-branch // now rebase off of some-other-branch


    ### Common Scenarios
    ### Common Git Scenarios

    Push some code changes up to github repo

  29. prograhammer revised this gist Jul 3, 2014. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions git-cheat-sheet.md
    Original file line number Diff line number Diff line change
    @@ -48,8 +48,8 @@ Switch to a branch

    Rebase the current branch off of some other branch (most of the time "some-other-branch" will be "master")

    git branch -l // shows you are on some-branch
    git rebase some-other-branch
    git branch -l // shows you are currently on some-branch
    git rebase some-other-branch // now rebase off of some-other-branch


    ### Common Scenarios
  30. prograhammer revised this gist Jul 3, 2014. 1 changed file with 7 additions and 6 deletions.
    13 changes: 7 additions & 6 deletions git-cheat-sheet.md
    Original file line number Diff line number Diff line change
    @@ -48,16 +48,17 @@ Switch to a branch

    Rebase the current branch off of some other branch (most of the time "some-other-branch" will be "master")

    git branch -l // shows you are on some-branch
    git rebase some-other-branch


    ### Common Scenarios

    Push some code changes up to github repo
    git init
    git remote add origin https://github.com/your-username/your-repo.git
    git add -A
    git commit -m "updated my package"
    git push --force origin master

    git init
    git remote add origin https://github.com/your-username/your-repo.git
    git add -A
    git commit -m "updated my package"
    git push --force origin master