# Git x GitHub --Allen-- --- ## What is Git? ---- Version Control ---- ![](https://i.imgur.com/3AMq2q3.jpg) ---- ![](https://i.imgur.com/HA9bC7k.png) ---- - History - Project (Collaboration) --- ## Let's get started! ---- Download ---- $ git config --global user.name "user" $ git config --global user.email "user@email" ---- $ vim ~/.gitconfig ---- ## Warm Up ---- $ git init ---- ![](https://i.imgur.com/uvnR8Kf.png) ---- ```git $ git add --all # add *ALL* files $ git add . # add all files in current folder $ git add *FileName* # add the file ``` ---- ```git $ git commit -m "New Commit" $ git commit -am "New Commit" # git add && git commit ``` ---- ``` $ git commit --amend ``` ---- ![](https://i.imgur.com/RI2JwST.jpg) --- ## See what we've done ---- ``` $ git log $ git log --oneline $ git log --graph $ git log --all ``` ---- ![](https://i.imgur.com/nQvWKFv.png) --- ## Let's move a bit further ---- Review a bit ![](https://i.imgur.com/STVPcZO.png) ---- ``` $ git branch branchName $ git checkout branchName $ git checkout -b branchName # create & checkcout ``` ---- ``` $ git checkout commitID ``` --- git merge ![](https://i.imgur.com/x0DVQg7.gif) ---- ``` $ git merge branchName # merge branchName to current branch ``` ---- conflict --- ## More to learn... ---- git diff ---- ``` $ git diff branch1..branch2 ``` --- ## GitHub ---- <div style="background-color: white"> <img src="https://i.imgur.com/RV0cIK9.png" /> </div> ---- What's GitHub ---- ![](https://i.imgur.com/ePmydYa.png) ---- ![](https://i.imgur.com/qnt6EZ7.png) --- ## Let's get started ---- create a new repository (repo) --- ## SSH --- if you are window users.... ---- openSSH ---- Settings -> Apps -> Optional features -> openSSH ---- - https://blog.alantsai.net/posts/2015/09/use-ssh-in-windows-for-github - beware: ed25519 --- if you are mac, linux users:) ---- ``` $ ssh-keygen -t ed25519 -C "your_email@example.com" $ cd ~/.ssh $ cat id_ed25519.pub ``` ---- github > settings > SSH and GPG keys > new SSH keys ``` $ ssh -T git@github.com ``` --- push it to the remote repo! ---- ``` $ git remote add origin <repo_url> $ git push -u origin currentBranch $ git pull ``` ---- git push -u origin currentBranch? ``` $ git push origin currentBranch $ git checkout currentBranch $ git branch -u origin/currentBranch ``` ---- Check the branches ---- ``` $ git branch $ git branch -r # remote $ git branch -a # all ``` --- Sometimes, you just don't care about others... ---- ![](https://i.imgur.com/t0djyVc.jpg) --- Need some idea from other? ---- ``` $ git clone <repo_url> ``` --- ## Other stff? ---- .gitignore
{"metaMigratedAt":"2023-06-16T20:07:47.085Z","metaMigratedFrom":"YAML","title":"Git x GitHub","breaks":true,"contributors":"[{\"id\":\"dd2e311c-6db4-4e6f-8e33-d37e4c6a2326\",\"add\":2864,\"del\":109}]"}
    351 views