github Flashcards
Version
git –version
Workflow
- git add .
- git commit -m [message]
- git push
check status of files
git status
Staging unstaged or untracked files
git add filename
git add dirname
git add .
committing staged files
git commit -m “message.”
What does SSH stand for?
Secure shell
checking for ssh file in project
in git bash:
ls -a -l ~/.ssh
checking for ssh file in project
in git bash:
ls -a -l ~/.ssh
How to generate an SSH key
in git bash, in the root directory:
ssh-keygen -t rsa -b 4096 -C “email address”
Concerning ssh keys, how can you get the ssh pid?
in git bash:
eval “$(ssh-agent -s)”
How to register ssh key or file?
in git bash:
ssh-add ~/.ssh/id_rsa
How to view current remote origins
git remote -v
How to remove a remote origin or destination
git remote rm origin
git remote rm destination
How to add a remote origin?
git remote add origin git@github.com:accountname/reponame
How to push repository to github?
git push -u origin master
How to acces the key of an .ssh file?
in git bash:
cat ~/.ssh/id_rsa.pub
How to test ssh connection?
in git bash:
ssh -T git@github.com
How to push to heroku?
git push heroku master
SSH key workflow
- check for existing key: ls -a -l ~/.ssh
- Generate a key: ssh-keygen -t rsa -b 4096 -C “email
address” - Check if keygen was succesful: eval “$(ssh-agent -s)”
- Register key: ssh-add ~/.ssh/id_rsa
- Access key in file: cat ~/.ssh/id_rsa.pub
- Setup SSH with provider
- Test connection: ssh -T git@github.com
General Git workflow
- git add .
- git commit -m “message.”
- git push origin master
How to clone a specific branch
git clone –single-branch –branch
Difference between git clone and git pull?
git clone is how you get a local copy of an existing repository to work on. It’s usually only used once for a given repository, unless you want to have multiple working copies of it around. (Or want to get a clean copy after messing up your local one…)
git pull (or git fetch + git merge) is how you update that local copy with new commits from the remote repository. If you are collaborating with others, it is a command that you will run frequently.
Difference between clone, pull, fork, and push
git clone means you are making a copy of the repository in your system.
git fork means you are copying the repository to your Github account.
git pull means you are fetching the last modified repository.
git push means you are returning the repository after modifying it.
In layman’s term:
git clone is downloading and git pull is refreshing.
How to see a list of git commits?
git log