๐Ÿšจ What to watch out for when using GitHub (Security – Hacking prevention)

๐Ÿšจ 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 Forkor Clonemay 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.

Leave a Comment

๋ชฉ์ฐจ