{"slug": "powershell-wednesday-git-101", "title": "PowerShell Wednesday Git 101", "summary": "This article provides a concise reference guide for essential Git commands, covering repository initialization, file tracking, committing, and remote setup. It also explains branching operations, including creation, switching, and deletion, as well as how to fetch and pull changes from a remote repository. Additionally, the guide clarifies that a Pull Request (PR) is functionally a \"Merge Request,\" as used by platforms like GitLab.", "body_md": "# PowerShell Wednesday - Git 101 \n\n---\n\n## `git init`\n\nInitialize a Git directory as a repository.\n`git init`\n\n---\n\n## `git add`\n\nTrack files with Git (A.K.A. Git now knows and cares about these files)\n\n`git add <filename>`\n\nor add everything in the folder\n\n`git add .`\n\n---\n\n## `git commit`\n\nCommit staged files to the repository history.\n\n`git commit -m \"your message here\"`\n\nor interactive commit message\n\n`git commit`\n\n---\n\n## `git remote`\n\nSet up a remote repository (e.g. GitHub, GitLab, etc.)\n**Most SCM providers will give you the command!**\n\n`git remote add origin <url>`\n\nView current remotes:\n\n`git remote -v`\n\n---\n\n## `git push`\n\nPush commits to a remote repository.\n\n`git push`\n\nPush and set the upstream tracking reference (first push of a branch):\n\n`git push -u origin <branch-name>`\n\nAfter `-u` is set once, future pushes from that branch only need:\n\n`git push`\n\n---\n\n## `git branch`, `git checkout`, and `git switch`\n\nCreate a new branch:\n\n`git branch <branch-name>`\n\nSwitch to an existing branch:\n\n`git checkout <branch-name>`\n\nor _(newer syntax)_:\n\n`git switch <branch-name>`\n\nCreate and switch in one step:\n\n`git checkout -b <branch-name>`\n\nor _(newer syntax)_:\n\n`git switch -c <branch-name>`\n\nList Branches:\n`git branch`\n\nRemove a branch:\n`git branch -d <branch-name>`\n\n---\n\n## `git pull` and `git fetch`\n\nFetch any branches from origin to your local working copy:\n\n`git fetch`\n\nPull any upstream changes into your working copy:\n\n`git pull`\n\n---\n\n## `git checkout`\n\nCheck out a specific commit (detached HEAD state — you're looking, not working):\n\n`git checkout <commit-hash>`\n\nCheck out a specific branch:\n\n`git checkout <branch-name>`\n\n---\n\n## Git Configuration Options\n\n```bash\n# Set user and email\ngit config --global user.name \"Your Name\"\ngit config --global user.email \"your.email@example.com\"\n\n# Set your commit editor\ngit config --global core.editor \"nvim\"\n```\n\n## Git Stages\n\n| Stage/State | Description |\n| --- | --- |\n| Untracked | File exists but Git has never been told about it. |\n| Staged _(Indexed)_ | `git add` was run for this file and Git is now tracking it. |\n| Modified _(Unstaged)_ | A committed file was edited. Git sees the difference but it is not staged yet. |\n| Committed | The file has been committed with `git commit` and is now part of the repo history. |\n| Ignored | Git has been instructed to ignore the file via _.gitignore_. |\n\n## Git SCMs\n\nThink of a Pull Request (PR) more as a \"Merge Request\".\nSome SCM platforms like Gitlab specifically call them MRs.\n", "url": "https://wpnews.pro/news/powershell-wednesday-git-101", "canonical_source": "https://gist.github.com/ephos/382e766be45dc4f606da7c0ec3063418", "published_at": "2026-04-29 17:42:49+00:00", "updated_at": "2026-05-22 18:39:05.671781+00:00", "lang": "en", "topics": ["developer-tools", "open-source"], "entities": ["Git", "GitHub", "GitLab"], "alternates": {"html": "https://wpnews.pro/news/powershell-wednesday-git-101", "markdown": "https://wpnews.pro/news/powershell-wednesday-git-101.md", "text": "https://wpnews.pro/news/powershell-wednesday-git-101.txt", "jsonld": "https://wpnews.pro/news/powershell-wednesday-git-101.jsonld"}}