Skip to content

Latest commit

 

History

History
executable file
·
102 lines (73 loc) · 2.98 KB

steps.md

File metadata and controls

executable file
·
102 lines (73 loc) · 2.98 KB

My First Github Experience - CLI

Creating a new repository from commandline

CLI Tasks

  • Step 1
    • Create a github repository named py1 using https
    • Initialize and add contents
  • Step 2
    • Create further files using echo
    • Add added/modified files using git add
    • Add comment using git commit -m
    • Push files to github using git push

Create Repo using curl

curl - Command line tools and libraries for URLs


curl -u 'DSBUSA' https://api.github.com/user/repos -d '{"name":"py1"}'

Initialize from CLI


mkdir py1
cd py

echo "# py1" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/DSBUSA/py1.git
git push -u origin master

Further Edits


# Create new file
echo "# Hello World" > hello.md
echo "## This is nice" >> hello.md
echo "* Adding line 1 " >> hello.md
echo "* Adding line 2 " >> hello.md

# Add this to the list of commits
git add hello.md
git commit -m "Added Hello World file hello.md"
git push

# Follow proompts to enter user and password info

Add a folder

  • Create newfolder
  • Create file(s) inside newfolder
  • Checkin newfolder along with files.
mkdir newfolder
echo "Folder 1 README" > newfolder/README.md
git add newfolder/README.md
git commit -m "Added newfolder"
git push

Add SSH access to repository using a key


# Generate Keys
  eval $(ssh-agent -s)
  ssh-keygen -t rsa -b 4096 -C "DSBUSA@github.com"
  ssh-add ~/.ssh/id_rsa

# Show your public key in terminal window
  cat ~/.ssh/id_rsa.pub


# Put keys on the server
  curl -u DSBUSA:PASSWORD https://api.github.com/user/keys -d '{"title":"KEY_NAME", "key":"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDaX6aUV9Pu7MzYjKwamWHJXKtIfXUnaXomwPYNoAedGvxNY9r20VPRHXz1RP8tKP6qB3P+lywlsSILdJ5T0SCc9ESC7fhTJeo/DqlYunvTbRpZrmWeZGJfJ4rZxuDXSdix+3ZxuilD6xl+uY+3QAfZeoeFDpsxt3bEhMvYzGQ6WsbP4oF+2pPXpmSGY4XmN8GdB6hsQKIg/26/paSdBTi6PgBy+BLXrXTHjEjIIawUaCmCXKTk2MJVkyPesEFj8kp8aLIXEERoll8d1aztuLf4SYdtoSSdfaIDo0GE+jJE/bdMqT/BKLKFifIOBY1SB+OCHyOLQQvGKwgZ5775wNGKm6rCCSBy3JMges8w0SXag+TEkc3eOqOYuVx0RJGljp1r4yU7kedK4OxP70vI8PquAKP9BcLdGQETrFUtCHtTXmzjEB1QbO5WlEh5By3W3SAbB0mqyh5TQvaqnOLqkyq28DP7Od/4JR90gTxkXRKCHAaCdTwGekAIni1bgscJ/GhESe2N6QF6z1GjLSFeJdH6L4cl56JLsHHDKxnHxIxDr0w10XFExQ87V5VnZ6vnq65UV1RoAXHKjEv99aAQEL5m8sGZLU3IiagbqEBSHGV80X0G3feTjsJ0BtxZxtFtsjGdSU/h7FcQElJJaGZ/LtGfr4jn/TvY3vVpYzW+U4eylw== DSBUSA@github.com"}'
  git push -u origin master

# Clone using SSH
  cd ~/proj/
  git clone git@github.com:DSBUSA/py1.git py3

Notes

  • Git configuration information is stored in ${HOME}/.gitconfig
    • Global configuration can be manipulated using git config --global user.name DSBUSA
    • Change name in gitconfig using git config --global
  • Cache credentials using git config --global credential.helper cache
  • Chain commands to say checkin steps.md over and over after modifications
    • git add steps.md ; git commit -m "Updated steps"; git push