A Personal Cheat Sheet of Git Commands (with Remotes)
If you were doing development all day long and software development were your main job, there probably wouldnโt be much to get confused about. However, since most developers are accustomed to the Git GUI provided by Visual Studio or VS Code, there are many times when Git commands simply donโt come to mind. For general development and version control, the level of functionality provided by those IDEs is usually sufficient, so itโs not a big problem. But whenever you need to type commands in the terminal, you end up searching the internet or relying on ChatGPT, which wastes unnecessary time. I took some time to write down only the parts I actually need.
0) One-time setup โ user environment configuration
git config --global user.name "Hong Gil-dong" git config --global user.email "gildong@example.com" # (Recommended on Windows) Checkout uses CRLF, commit uses LF git config --global core.autocrlf true
If you use SSH:
# Generate a key if you donโt have one ssh-keygen -t ed25519 -C "gildong@example.com" # Register the public key in Gitea Web > Settings > SSH Keys type ~/.ssh/id_ed25519.pub # Windows PowerShell cat ~/.ssh/id_ed25519.pub # Linux/macOS
1) Starting a new project (code already exists locally)
In the Gitea web UI, create a New Repository โ empty repository (For example :
vision-utils).cd ~/work/vision-utils # project folder git init git add . git commit -m "Initial commit" git branch -M main # Example SSH URL (varies by company) git remote add origin ssh://git@<gitea_host>:222/<org>/<repo>.git git push -u origin main
โถ If you use HTTPS:
git remote add origin https://<gitea_host>/<org>/<repo>.git git push -u origin main # Enter a Personal Access Token instead of a password
2) Joining an existing project (clone โ branch โ PR)
git clone ssh://git@<gitea_host>:222/<org>/<repo>.git cd <repo> # Working branch git switch -c feature/cali-ui # After editing/saving files git add . git commit -m "Add calibration overlay" git push -u origin feature/cali-ui
Open a Pull Request in the Gitea web UI and proceed with review/merge.
3) Daily-use basic commands (cheat sheet)
Pulling updates
git switch main git pull --ff-only # fast-forward๋ก ์ต์ ๋ฐ์
Feature / Bug fix
git switch -c fix/bug-101 # edit files git add . git commit -m "Fix bug 101" git push
Rebase with latest mainย
git fetch origin git rebase origin/main # ๋ด ๋ธ๋์น๋ฅผ main ์๋ก ์ฌ์ ๋ ฌ # ์ถฉ๋๋๋ฉด ํ์ผ ์์ โ git add <์์ ํ์ผ> โ git rebase --continue git push --force-with-lease
Merge locally instead of Web UI
git switch main git pull --ff-only git merge --no-ff feature/cali-ui git push
Safe rollback commands
git restore <ํ์ผ> # ์ํนํธ๋ฆฌ ๋ณ๊ฒฝ ์ทจ์ git restore --staged <ํ์ผ> # add ์ทจ์ git revert <์ปค๋ฐํด์> # ๋๋๋ฆฌ๋ ์ ์ปค๋ฐ ์์ฑ(๊ณต์ ๋ธ๋์น ์์ )
Tag / Release
git tag -a v1.0.0 -m "first release" git push origin v1.0.0 # Gitea Releases ํญ์์ ๋ฆด๋ฆฌ์ค ๋ ธํธ ์์ฑ ๊ฐ๋ฅ
4) Git LFS(Large Files)
git lfs install # ์ต์ด 1ํ git lfs track "*.bin" "*.pt" # ์ถ์ ํจํด git add .gitattributes git add large_model.pt git commit -m "Track with LFS" git push
5) Quickย .gitignore ย (C++ / Python mix)
# build outputs build/ dist/ *.o *.obj *.exe # Python __pycache__/ *.pyc .venv/ # IDE .vscode/ .idea/
Commit :
git add .gitignore git commit -m "Add .gitignore" git push
6) .gitignore(For Visual Studio)
# --- Build / Binaries --- build/ build-*/ out/ bin/ obj/ *.o *.obj *.so *.dll *.lib *.a *.exe *.pdb *.ilk *.exp # --- CMake --- CMakeFiles/ CMakeCache.txt cmake-build-*/ install_manifest.txt _compile_commands.json Makefile CTestTestfile.cmake *.cmake.user # --- Visual Studio / MSBuild --- .vs/ Debug*/ Release*/ x64/ x86/ ipch/ *.sdf *.opensdf *.vcxproj.user *.vc.db *.user *.log # --- Visual Studio Code / JetBrains --- .vscode/ .vscode-test/ .idea/ *.iml # --- Python --- __pycache__/ *.pyc *.pyo *.pyd *.egg-info/ .eggs/ .venv/ venv/ .env .env.* dist/ build/ pip-wheel-metadata/ # --- Notebooks / data (์ํ๋ฉด ์ฃผ์ ํด์ ) --- # *.ipynb_checkpoints/ # data/ # datasets/ # --- Tests / coverage --- .coverage htmlcov/ .pytest_cache/ # --- Images / Models (LFS ์ฌ์ฉ ์ ์ฃผ์ ํด์ ) --- # *.pt # *.onnx # *.bin # *.weights # --- OS / Tools --- .DS_Store Thumbs.db desktop.ini # --- Logs / temp --- *.log *.tmp tmp/ .cache/
For MFC or specific development frameworks, itโs a good idea to prepare separate .gitignore templates. I plan to keep updating them as needed.
ย
