๐จ Important Considerations When Using GitHub (Security and Hacking Prevention)
1. Be cautious with files containing sensitive information
- Never upload important information like passwords, API keys (authentication keys), or personal information!
- Information uploaded to GitHub can be easily viewed by others.
๐ช Analogy:
- It's like leaving your house key in front of your doorโanyone can walk right in.
๐ก Example solution:
# ์๋ชป๋ ์ (๋ฏผ๊ฐํ ์ ๋ณด ์ง์ ํฌํจ โ)
API_KEY = "123456789abcdef"
# ์ฌ๋ฐ๋ฅธ ์ (๋ณ๋ ํ์ผ๋ก ๊ด๋ฆฌ โ
)
.env ํ์ผ์ ์ ์ฅ ํ, .gitignore๋ก ๊ด๋ฆฌ
2. Always use the `.gitignore` file
- Specify files that should not be uploaded to Git to prevent accidental uploads.
๐ช Analogy:
- It's like hiding important items in a safe so others can't see them!
๐ก Usage Example:
# .gitignore
.env
password.txt
node_modules/
__pycache__/
3. Always verify before committing and pushing
- Don't commit or push hastilyโalways double-check your file contents!
๐ช Analogy:
- It's like the habit of rereading a message before sending it to a friend to avoid sending the wrong content!
๐ก Good Habit Example:
git status # ๋ณ๊ฒฝ๋ ํ์ผ ๋ชฉ๋ก ๋ณด๊ธฐ
git diff ํ์ผ๋ช
# ํ์ผ ๋ด ๋ณ๊ฒฝ ๋ด์ฉ ํ์ธ
4. Be especially careful with public repositories
- Public repositories are visible to anyone on the internet.
- Always store sensitive information in private repositories or manage it separately.
๐ช Analogy:
- Wouldn't it be risky to post your personal information on a bulletin board anyone can see?
5. Beware of hacking risks when forking or cloning
- When forking or cloning a project created by someone else
ForkorClonemay contain hacking code or malicious code.
๐ช Analogy:
- Wouldn't it be risky to just plug a USB drive given by a stranger into your computer?
๐ก Prevention method:
- Only use official and trustworthy projects.
- After downloading code, always verify the file contents!
Points to note when using Git commands (commit, branch, merge, push, pull, etc.)
1. Commit Precautions
- Write meaningful commit messages. (This makes it easy to understand what changes were made later!)
Good example โ
git commit -m "feat(login): ๋ก๊ทธ์ธ ๋ฒํผ ์ถ๊ฐ"
Bad example โ
git commit -m "์์ "
๐ 2. Branch Precautions
- Do not work directly on the main branch. It's better to work on a separate branch and then merge it.
Example of creating a branch
git checkout -b feat/login-page
๐ช Analogy:
- Think of it like drafting (on a separate branch) and then moving it to the original (main branch) once complete!
๐ 3. Merge Precautions
- Always check for and resolve conflicts before merging.
Example of resolving conflicts
# ๋ธ๋์น ์ ํ ๋ฐ ๋จธ์ง
git checkout main
git merge feat/login-page
๐ช Analogy:
- Imagine two different people writing on the same note at the same timeโyou'd need to neatly organize the overlapping content, right?
๐ 4. Push Precautions
- Always double-check file contents before pushing, and correct any incorrect commits before pushing.
Push Command Example
git push origin main
๐ช Analogy:
- Like double-checking before sending an email or message!
๐ 5. Pull Precautions
- Always update to the latest state before starting work (
git pull) to incorporate others' changes.
Pull command example
git pull origin main
๐ช Analogy:
- When writing a shared note with a friend, if they added content first, it's best to review their changes before starting your work!
โ Must-remember one-line summary tip!
- Never upload sensitive information to GitHub, and always double-check your file contents! ๐๐
By carefully following these basic security and precautionary measures, you can use Git and GitHub safely and effectively.
