Installing and Using Git on Windows
Installing Git on Windows: My Usual Method
Here’s a straightforward guide to installing Git on Windows:
Download the Latest Version
Go to Git’s official download page and download the latest version for Windows.Run the Installer as Administrator
Right-click the downloaded installer and select “Run as administrator.”Follow the Installation Wizard
- Information Screen: Click “Next.”
- Select Destination Folder: Click “Next” (accept the default option).
- Select Components: add "Add a Git Bash to windows Terminal" then click “Next.”
- Select Start Menu Folder: Click “Next” (accept the default option).
- Choosing the Default Editor: Select Notepad++ or Notepad, then click “Next.”
- Adjusting the Name of the Initial Branch: Click “Next” (accept the default option).
- Adjusting Your PATH Environment: Click “Next” (accept the default option).
- Choosing SSH Executable: Click “Next” (accept the default option).
- Choosing HTTPS Transport Backend: Select “Use the native Windows Secure Channel library,” then click “Next.”
- Configuring Line Endings: Click “Next” (accept the default option).
- Configuring the Terminal Emulator: Click “Next” (accept the default option).
- Choose the Default Behavior of 'git pull': Click “Next” (accept the default option).
- Choose Credential Helper: Click “Next” (accept the default option).
- Configure Extra Options: Click “Next” (accept the default options).
- Configure Experimental Options: Click “Install” (accept the default options).
Complete the Setup
After installation, uncheck any additional tasks and click “Finish.”
This method is my usual approach and will get Git up and running, which is the basis for tracking all scripts, config files, and notes that I will be using during this test lab project.
There are very many remote Git repo servers available, as covered in the previous post you do not have to have a server to use Git effectively on your own, but for anything that may need collaboration you will, so its a good idea to know how to set this up. I cant cover every single implementation here, but they all work in more or less the same way. For this project I will use GitHub, which is well known as the home to large number of opensource projects and gives the option for private repositories too
for more information see the Git documentation here
To recap create a new repo on your own machine
git init
git add .
git status
git commit -m "first commit"
git log
To publish your local repo to the server
git remote add origin [your URL]
git push -u origin master
Git credential manager will prompt you to log in you should select sign in with a code
Visit the URL shown and enter the code that is generated
Click Authorize git-ecosystem
Once you are authenticated your repository will be replicated to the server, you can check the status after this completes by running
git remote -v
This will show the origin push and pull url of your server
You can then navigate to your repository on the github page and you will see the files that you have pushed up to the remote server
Git Workflow
- reconcile the status of your local folder with the server
#check local folder with server
git fetch origin master
git log --graph --decorate --oneline
git checkout master
git merge --ff-only origin/master
git status
- Stage one or more changes
#one change
either stage one change
git add "name of file(s) to stage changes"
#or stage all changes
git add -A
- Commit changes to local repo
#commit changes to local
git status
git commit
- Push local commits to server
#push local commits to server
git push origin
#or if above errors (is used to map a branch in your local to a branch on remotegit push --set-upstream origin master)
- See a visual representation of your repository
git fetch origin master
git status
git log --graph --decorate --oneline
A note on the master/main branch naming convention.
I am based in the UK so i dont personally have an issue with using the term master branch, in some cultures this may be more sensitive especially in the United States.
In fields like engineering, technology, and craftsmanship, the term "master" has been used for centuries to refer to expertise, control, or the primary element in a system. For example:
- A master craftsman is someone with a high level of skill in a trade.
- A master copy refers to the original from which duplicates are made.
These technical uses predate and are independent of the associations with slavery that the word gained in other contexts, particularly in the U.S.
However, some organisations (github included) have chosen to move away from master terminology due to the sensitivity around the word's historical connotations in certain parts of the world. But in its pure engineering or technical use, "master" has a neutral meaning tied to expertise or system hierarchy
you can call the main/master branch anything really as long as you stick to that convention to avoid confusion later on
Comments
Post a Comment