Git & GitHub Essentials for Developers

Git & GitHub Git tracks your code changes and keeps your work safe. GitHub stores that code online so teams can share and collaborate. Git saves. GitHub shares. Git Commands You Actually Use One-time setup (tell Git who you are): git config --global user.name "Atif" - (set your name for all commits) git config --global user.email "atif@gmail.com" - (set your email for all commits) Start a project: git init - (start Git in the current folder) git status - (check changed, staged, and untracked files) git add . - (add all files to staging) git commit -m "initial commit" - (save changes with a message) Connect & share code: git remote add origin https://lnkd.in/gTef8QCr - (connect local project to GitHub repo) git pull origin main - (get latest code from GitHub) git push origin main - (upload your code to GitHub) Work safely with branches: git branch feature/login - (create a new branch) git checkout feature/login - (switch to that branch) git checkout -b bugfix/api-error - (create and switch branch together) git merge feature/login - (merge branch into current branch) Contribute to other repositories: git clone https://lnkd.in/gTef8QCr - (download a repo from GitHub) git checkout -b feature/update-readme - (create a new branch for your changes) git add . - (add all updated files) git commit -m "updated README" - (save your changes) git push origin feature/update-readme - (push branch to GitHub for PR) Fix mistakes: git diff - (see changes before commit) - Use when you want to check what changed before committing git log - (see commit history) - Use when you want to see commit history git restore filename - (undo file changes) - Use when you want to undo changes in a file git stash - (temporarily save work without commit) - Use when you want to pause work without committing git stash pop - (bring stashed work back) - Use when you want to resume stashed work #Git #GitHub #DeveloperJourney #Learning

  • No alternative text description for this image

To view or add a comment, sign in

Explore content categories