Showing posts with label GIT. Show all posts
Showing posts with label GIT. Show all posts

Tuesday, 12 September 2017

Gitlab cloning other dependent private repositories during ci pipeline

If we need to clone any other private repositories during the GitLab `ci` pipeline process, we can use the below command to run the on the `bash` script to copy the source code from another project.
The Job environment variable CI_JOB_TOKEN can be used to authenticate any clones of dependent repositories. For example:
git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.com/myuser/mydependentrepo
It can also be used for system-wide authentication (only do this in a docker container, it will overwrite ~/.netrc):
echo -e "machine gitlab.com\nlogin gitlab-ci-token\npassword ${CI_JOB_TOKEN}" > ~/.netrc
Gitlab Source

Wednesday, 5 April 2017

To prevent pushing the file permission in local into git repo (MacOS)

After switching to MacOS, I had to change the my applications's files permissions due to MAC permissions issue to run the application.

Afterwards, I made a commit and pushed to the Git Repo, however the modified file's permission also included on the push to the Git Repo.

Indeed, I do not want to include those permission which I have done for my local only and I have to reset my commit on the remote repo.

To prevent happening that, please follow the steps below:

1. Check the filemode status on git config:
$ git config -l

Output may contain below:
$ core.filemode=true

2. If it set as true, run the below command to set to false which will prevent including the file permission on the commits.
$ git config core.filemode false

3. Instead, run below command if you want to change the git configuration globally to apply on all the applications:
$ git config --global core.filemode false

Thursday, 15 December 2016

Configure the Project Specific Git Author/User Credential

If you working for two projects (may be one for work specific and another personal project) and you would like to configure the Git Author/User credential different for both, I mean as a project specific rather than as a global one.

You may have configured or can set as global credential as:
# To check the git configuration
git config -l

# To set the global git configuration
git config --global user.name "RC"
git config --global user.email "rc@example.com"
Now to change the credential for a project. First go the the project branch and check what's the credential it has and override with new credential using below command
# Go to the project folder first and make sure you already have git initiated.
cd ~/apps/project_folder

# To check the git configuration
git config -l

# To overwrite the name
git config user.name "RC Pro"

# To overwrite the email
git config user.email "personal@example.com"

Then, you all set for that.

Check Git for more

Thursday, 12 May 2016

List of Laravel Artisan Shortcuts (Alias) for Windows and MacOS

I would like to share the list of command alias I have created on my local to minimise the keystrokes with the Team.

Please go to the project root location via command line and just copy the below line (one line string) and run it:

alias cda="composer dump-autoload"; alias ci="composer install"; alias cu="composer update"; alias bi="bower install"; alias bu="bower update"; alias gi="gulp install"; alias ni="npm install"; alias pa="php artisan"; alias pam="php artisan migrate"; alias pamr="php artisan migrate:rollback"; alias pads="php artisan db:seed"; alias pades="php artisan db-exporter:seed"; alias pamm="php artisan make:migration"; alias pamc="php artisan make:controller"; alias pammd="php artisan make:model"; alias t="phpunit"; alias dat="php artisan app:droptables"; alias ga="git add"; alias gaa="git add ."; alias gc="git commit -m"; alias gp="git push"; alias gs="git status"; alias gl="git log"

The detail of the above string shortcut is below (if you want other way, feel free to change it with your comfort):

#Composer
alias cda="composer dump-autoload"
alias ci="composer install"
alias cu="composer update"

# Bower
alias bi="bower install"
alias bu="bower update"

# Gulp
alias gi="gulp install"
alias ggw="gulp && gulp watch"
# NPM alias ni="npm install" # Laravel alias pa="php artisan" alias pam="php artisan migrate" alias pamr="php artisan migrate:rollback" alias pads="php artisan db:seed" alias pades="php artisan db-exporter:seed" alias pamm="php artisan make:migration" alias pamc="php artisan make:controller" alias pammd="php artisan make:model" alias t="phpunit" # Laravel Custom alias dat="php artisan app:droptables" # Git alias ga="git add" alias gaa="git add ." alias gc="git commit -m" alias gp="git push" alias gs="git status" alias gl="git log"

Thursday, 26 November 2015

Bash (npm install) - Couldn't install optional dependency: Unsupported

If you are tyring to install any NPM packages, but stuck in the middle facing below issue:
"Couldn't install optional dependency: Unsupported"

npm WARN install Couldn't install optional dependency: Unsupported

> bufferutil@1.2.1 install C:\xampp\htdocs\myProject\node_modules\bufferutil
> node-gyp rebuild

C:\xampp\htdocs\wandle\node_modules\bufferutil>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node  rebuild )
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
gyp ERR! stack     at failNoPython (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:116:14)
gyp ERR! stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:71:11
gyp ERR! stack     at FSReqWrap.oncomplete (fs.js:82:15)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\xampp\htdocs\myProject\node_modules\bufferutil
gyp ERR! node -v v5.1.0
gyp ERR! node-gyp -v v3.0.3
gyp ERR! not ok
npm WARN install:bufferutil@1.2.1 bufferutil@1.2.1 install: `node-gyp rebuild`
npm WARN install:bufferutil@1.2.1 Exit status 1

> utf-8-validate@1.2.1 install C:\xampp\htdocs\myProject\node_modules\utf-8-validate
> node-gyp rebuild

Please run the below command first and try to install again, it should be fine afterwards:
$ git config --global url."https://".insteadOf git://

Tuesday, 24 November 2015

Configure the GIT & Clone the GIT Repository in Windows 7

·         Firstly, install the GIT from here https://git-scm.com/downloads if you do not have already installed.
·         Next, we need to generate the SSH Keys before we configure for Git:
Open the Git Bash, and try the following command:
$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/username/.ssh/id_rsa):

Either press Enter to generate it on the above default location or you can specify it after colon (: ) as per your preference -  eg. /c/Keys/.ssh/id_rsa
And, enter the Passphrase which will require for using git activities for authentication.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/username/.ssh/id_rsa.
Your public key has been saved in /c/Users/username/.ssh/id_rsa.pub.
The key fingerprint is:
d0:82:24:8e:d7:f1:bb:9b:33:53:96:93:49:da:9b:e3 username@mypc.local

To verify it, you can try typing below command:
$ cat /c/Users/username/ssh/id_rsa.pub

ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAklOUpkDHrfHY17SbrmTIpNLTGK9Tjom/BWDSU
GPl+nafzlHDTYW7hdI4yZ5ew18JH4JW9jbhUFrviQzM7xlELEVf4h9lFX5QVkbPppSwg0cda3
Pbv7kOdJ/MTyBlWXFCR+HAo3FXRitBqxiX1nKhXpHAZsMciLq8V6RjsNAQwdsdMFvSlVK/7XA
t3FaoJoAsncM1Q9x5+3V0Ww68/eIFmb1zuUFljQJKprrX88XypNDvjYNby6vw/Pb0rwert/En
mZ+AW4OZPnTPI89ZPmVMLuayrD2cE86Z/il8b+gw3r3+1nKatmIkjn2so1d01QraTlMqVSsbx
NrRFi9wrf+M7Q== username@mypc.local

Adding the SSH Keys to Git for Authentication
$ ssh-add /c/Users/ username/ssh/id_rsa

To check the ssh-agent:  
$ ssh-agent –s

To check the agent id:   
$ eval $(ssh-agent)

To check agent identitiy
$ ssh-add –l

To check the Tunnelling:
$ ssh -T git@git.yourdomain.com OR your_git_repository_url
To clone the project from GIT Repository
$ git clone git@git.yourdomain.com or your_git_repository_url

Eg. your_git_repository_url  = https://github.com/laravel/laravel.git

Thursday, 22 May 2014

GIT - ignore committing list of unnecessary files ( using .git/info/exclude )

If you are using GIT for version control, there is way you can ignore committing unnecessary files as per required.
Step 1. And to do that, please open a project_folder/.git/info/exclude file then update the file as per below example;
# git ls-files --others --exclude-from=.git/info/exclude
# Lines that start with '#' are comments.
# For a project mostly in C, the following would be a good set of
# exclude patterns (uncomment them if you want to use them):
# *.[oa]
# *~

# Your Main Application files (Example for CodeIgniter based application) #
######################
/.idea/*
/assets/_upload/_articles/* // * mean exclude all the files
/assets/_upload/_tmp/*

!/assets/_upload/_articles/index.html // ! mean not exclude this file
!/assets/_upload/_tmp/index.html

/application/config/config.php 
/application/config/database.php 

/application/cache/*
/application/cache/templates_compiled/*
/application/CachedWebContent/*
/application/logs/*

/error_log

Basic exclude rules for CodeIgniter based application as below; if you like you can modify them as per your needs.

# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
 
# Packages #
############
# it's better to unpack these files and commit the raw source
# git has its own built in compression methods
*.7z
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar
*.zip
 
# Logs and databases #
######################
*.log
*.sql
*.sqlite
 
# OS generated files #
######################
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db
Step 2. Edit the file and Save it.
Step 3. Then clean the previous cached rules if any. Run below code each time you modified the exclude file

# git reset HEAD

Step 4.

# git add -- all // Add all the new folders or files if you have added any
# git commit -am "You comments for commit"
# git push
#
That's all you need to know! Enjoy!!!

Git Clone local repository to another repository, Exclude some folder

// Git Clone local repository to another repository
// -----------------------------------------------
$ mkdir c/xampp/htdocs/repo1 // create repository one
$ cd c/xampp/htdocs/repo1 // Go into folder
$ git init // initialise the git
$ git add -all // All all the file and folder

// To clone all the files except particular folders
// -----------------------------------------------
$ git reset -- folder1/ folder2/ // Exclude the folder1, folder2 from committing


// To clone to another local directory 
// -----------------------------------------------
$ git clone path_to_repository1/ path_to_another_repository/

$ git pull // To pull the updates from repo1.

Friday, 4 April 2014

To add to one GIT repository to another repository on same machine

Well, what I have done here is I have development and production repositories on my PC which were exclusively linked to their own GitHub repositories.

Now, I would like to update my production repo from development locally and push back to production repository on GitHub.

And here is my commands;

# Go to local "production" repo
 
$ cd project.production/  
RC@MyPC-001 /c/xampp/htdocs/project.production (master)

$ git remote add development /c/xampp/htdocs/hillingdon/dev.hcp.branch
RC@MyPC-001 /c/xampp/htdocs/project.production (master)

$ git fetch development

$ git merge development/
development/forum-devt   development/master // This is because I had two branch on my development repo

$ git merge development/master // I am merging the master branch only

// If you got any conflicts, please resolve them and add them all
 
$ git add --all