Showing posts with label git. Show all posts
Showing posts with label git. Show all posts

Monday, June 24, 2024

[macOS] Git File Locking

 


Install Git LFS


Before getting started, make sure you have Git LFS installed in your computer. Open a terminal window and run:

git-lfs --version


If it doesn’t recognize this command, you must install it. There are several installation methods that you can choose according to your OS. To install it with Homebrew:

brew install git-lfs


Once installed, open your local repository in a terminal window and install Git LFS in your repository. If you’re sure that LFS is already installed, you can skip this step. If you’re unsure, re-installing it does no harm:

git lfs install

For more information, see Git Large File Storage (LFS).

Lock files

By locking a file, you verify that no one else is editing it, and prevent anyone else from editing the file until you’re done. On the other hand, when you unlock a file, you communicate that you’ve finished editing and allow other people to edit it.

To lock or unlock a file with Exclusive File Locking, open a terminal window in your repository directory and run the commands as described below.

To lock a file:

git lfs lock path/to/file.png


To unlock a file:

git lfs unlock path/to/file.png


You can also unlock by file ID (given by LFS when you view locked files):

git lfs unlock --id=123


If for some reason you need to unlock a file that was not locked by yourself, you can use the --force flag as long as you have Maintainer permissions to the project:

git lfs unlock --id=123 --force


You can push files to GitLab whether they’re locked or unlocked.


Monday, June 6, 2022

VS Code: Fixing Git Certificate Issues


Ref: https://dougdefrank.wordpress.com/2018/02/28/vs-code-fixing-git-certificate-issues/ 

git config --system http.sslBackend schannel



Sunday, June 5, 2022

GitLab Docker


 Ref:https://docs.gitlab.com/ee/install/docker.html

Set up the volumes location

Before setting everything else, configure a new environment variable $GITLAB_HOME pointing to the directory where the configuration, logs, and data files will reside. Ensure that the directory exists and appropriate permission have been granted.


For Linux users, set the path to /srv/gitlab:


export GITLAB_HOME=/srv/gitlab


For macOS users, use the user’s $HOME/gitlab directory:


export GITLAB_HOME=$HOME/gitlab


The GitLab container uses host mounted volumes to store persistent data:


Local location Container location Usage

$GITLAB_HOME/data /var/opt/gitlab For storing application data.

$GITLAB_HOME/logs /var/log/gitlab For storing logs.

$GITLAB_HOME/config /etc/gitlab For storing the GitLab configuration files.

Installation

The GitLab Docker images can be run in multiple ways:


Using Docker Engine

Using Docker Compose

Using Docker swarm mode

Install GitLab using Docker Engine

You can fine tune these directories to meet your requirements. Once you’ve set up the GITLAB_HOME variable, you can run the image:


sudo docker run --detach \

  --hostname gitlab.example.com \

  --publish 443:443 --publish 80:80 --publish 22:22 \

  --name gitlab \

  --restart always \

  --volume $GITLAB_HOME/config:/etc/gitlab \

  --volume $GITLAB_HOME/logs:/var/log/gitlab \

  --volume $GITLAB_HOME/data:/var/opt/gitlab \

  --shm-size 256m \

  gitlab/gitlab-ee:latest


This will download and start a GitLab container and publish ports needed to access SSH, HTTP and HTTPS. All GitLab data will be stored as subdirectories of $GITLAB_HOME. The container will automatically restart after a system reboot.


If you are on SELinux, then run this instead:


sudo docker run --detach \

  --hostname gitlab.example.com \

  --publish 443:443 --publish 80:80 --publish 22:22 \

  --name gitlab \

  --restart always \

  --volume $GITLAB_HOME/config:/etc/gitlab:Z \

  --volume $GITLAB_HOME/logs:/var/log/gitlab:Z \

  --volume $GITLAB_HOME/data:/var/opt/gitlab:Z \

  --shm-size 256m \

  gitlab/gitlab-ee:latest


This will ensure that the Docker process has enough permissions to create the configuration files in the mounted volumes.


If you’re using the Kerberos integration , you must also publish your Kerberos port (for example, --publish 8443:8443). Failing to do so prevents Git operations with Kerberos.


The initialization process may take a long time. You can track this process with:


sudo docker logs -f gitlab


After starting a container you can visit gitlab.example.com (or http://192.168.59.103 if you used boot2docker on macOS). It might take a while before the Docker container starts to respond to queries.


Visit the GitLab URL, and log in with username root and the password from the following command:


sudo docker exec -it gitlab grep 'Password:' /etc/gitlab/initial_root_password

Thursday, May 19, 2022

Remove credentials from Git

 


Ref: https://stackoverflow.com/questions/15381198/remove-credentials-from-git

If this problem comes on a Windows machine, do the following.

  • Go to Credential Manager

    • in German, it is called: Anmeldeinformationsverwaltung
    • in French, it is called: Gestionnaire d'identification
    • in Polish, it is called: Menedżer poświadczeń
    • in Portuguese, it is called: Gerenciador de Credenciais
    • in Russian, it is called: Диспетчер учётных данных
    • in Spanish, it is called: Administrador de credenciales
  • Go to Windows Credentials

  • Delete the entries under Generic Credentials


  • Try connecting again. This time, it should prompt you for the correct username and password.

Configure your Git username/email

Ref:https://support.atlassian.com/bitbucket-cloud/docs/configure-your-dvcs-username-for-commits/ 

Configure your Git username/email

You typically configure your global username and email address after installing Git. However, you can do so now if you missed that step or want to make changes. After you set your global configuration, repository-specific configuration is optional.

Git configuration works the same across Windows, macOS, and Linux.

To set your global username/email configuration:

  1. Open the command line.

  2. Set your username:
    git config --global user.name "FIRST_NAME LAST_NAME"

  3. Set your email address:
    git config --global user.email "MY_NAME@example.com"

To set repository-specific username/email configuration:

  1. From the command line, change into the repository directory.

  2. Set your username:
    git config user.name "FIRST_NAME LAST_NAME"

  3. Set your email address:
    git config user.email "MY_NAME@example.com"

  4. Verify your configuration by displaying your configuration file:
    cat .git/config

Install and use xorg-server on macOS via Homebrew

  The instructions to install and use xorg-server on macOS via Homebrew: Install Homebrew (if you haven't already): /bin/bash -c ...