🚨 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.