For this example, the directory git and subdirectory portfolio
will be used — portfolio will become the new repository.
Create the Directory
New-Item -Path '.\Git\Portfolio' -ItemType Directory
Some individuals use the -Force flag to ensure that both directories are
created if they don't already exist. This has not been necessary in practice, so it is
not included here.
Confirm with ls:
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 2/22/2024 10:18 AM Portfolio Initialize the Repository
-
Change into the directory:
cd Portfolio -
Initialize the repository:
git initA
.gitfolder is created containing Git's records and configuration files. Do not edit these files manually.Mode LastWriteTime Length Name ---- ------------- ------ ---- d--h-- 2/22/2024 10:57 AM .git
Add a Remote
Adding a remote tells Git that your new remote repository is tied to this local folder.
git remote add origin git@gitlab.com:ellopunk/portfolio.git Create a README File
The best practice is to start with a README.md file. It should provide
essential information about the project — what it is, how to use it, and how to contribute.
New-Item README.md First Commit and Push
- Stage the file:
git add README.mdgit addmoves changes from the working directory to the staging area, telling Git which modifications to include in the next commit. - Commit:
git commit -S -m "Initializing Project"-m— every commit requires a message; write something that communicates the intent of the changes.-S— signs the commit with your GPG key. See Signing Git Commits Using PowerShell.
- Push:
git push --set-upstream origin mastergit push— uploads local repository content to a remote repository.--set-upstream— sets the default upstream branch for the current local branch.origin— the remote repository to push to.master— the branch on the remote to push to.
ⓘmainand other names are now commonly used as the default branch to move away from the master/slave terminology.
Your project is ready. Confirm by visiting your GitLab (or GitHub) page.