Tinus EngOps Wiki

Logo

OpsaC - Operating as PowerShell code

Links

Home

IT-Wiki

PowerShell Blog

PowerShell Index

PowerShell Search

Additional Websites

View my GitHub Profile

View my GitHub Gists

View my Codeberg Page

View my Photo Website

Git Basics

published: February 6, 2021 author: Tinu tags: PowerShell categories: GitLab


Table of Contents

Git offline Installation

VSCode integrates Git version control. Download and install Git.

Download Source

Git Configuration

Git global settings are saved in "$($env:USERPROFILE)\.gitconfig" while local settings are saved in the root folder of the respective project.

The global settings can be set from "$($env:USERPROFILE)\.gitconfig" to another path by setting the environment variable HOME to the desired path (Example: $env:home = 'D:\github').

List global settings

git config --global -l

List system settings

git config --system -l

these settings can only be changed with admin rights.

Show all settings

Show all settings of all gitconfig-files:

git config --list --show-origin

Define identity with name and email

git config --global user.name "John Doe"
git config --global user.email johndoe@example.com

gitconfig:

[user]
     name = John Doe
     email = johndoe@example.com

Proxy

gitconfig:

[http "https://gitlab.company.int"]
	proxy = http://proxy.company.int:8080/
[credential]
	helper = wincred
[credential "https://gitlab.company.int"]
     username = 'Tinu'

If you need Proxy credentials then you can create a file .netrc and putting the settings in to this file.

netrc:

machine <Fully qualified name of the proxy>
login <login user>
password <password>

gitconfig:

[http]
     sslverify = true
     sslBackend = schannel
	proxy = http://proxy.company.int:8080/
[user]
     name = John Doe
     email = johndoe@example.com
[credential "https://gitlab.company.int"]
     username = 'tinu'

Work with Git

Working with a remote Repository like GitLab.

Git

Git clone

The first thing that you should do, is to clone the remote Repository to a locale Repository.

git clone <git-url>

Working Directory

If you have a locale Repository, then you also have a local working area (WorkingDir).

In this directory, you make your changes like add folders/files, update/remove folders/files.

But before you make a change, please create a new branch.

Create new branch

git checkout -b <new_branch>

Make your changes in the new branch and add the changes to the local staging area.

Staging

git add <file to add> # or git add . to stage all changes

Commit

Commit your changes to your local Repository.

git commit -m "Commit message"

Update remote repository

If all changes are commited, then push the branch to the remote Repository.

git push --set-upstream origin <new_branch>

Merge

In GitLab you have to create a Merge Request to merge the new_branch in to the main branch and merge it.

Update local Repository

After the Merge ist completed, you should update your local Repository.

Switch to the main branch:

git switch main

Update the main branch:

git pull

List all local branches

git branch

Remove branch

git branch -d <new_branch>
git branch -D <new_branch> # delete force

GitHub

If you work in a Team on GitHub, then every Member should make a Fork of the remote Repository.

Git

See also

git –fast-version-control.


← Previous Post ◇ [ Top ] ◇ Copyright © 2024 by tinuwalther ◇ [ Blog ] ◇ Next Post →