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

Thursday, March 28, 2024

Sync multiple git repo at once

Use the following command in Linux will do the job:

 ls -d RepoNames* | xargs -I{} git -C {} pull

Wednesday, June 14, 2023

Watch git log automatically

Linux one-liner to watch and refresh git log every 30 secs:

watch --color -n 30 "git fetch; git log origin/master -30 --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --color=always"






Thursday, July 16, 2020

Add git information to your bash prompt

To show git information in your bash prompt, add the following function in your ~/.bashrc

function git-shell() {
  export GIT_PS1_SHOWDIRTYSTATE=1
  export PS1='\[\033[01;33m\] (git) \[\033[01;34m\]\w$(__git_ps1 " \[\033[01;32m\](%s)")\[\033[00m\]\n\$ '
}

Then, in your bash, run "git-shell" and you will get a nice git prompt:

 (git) /path_to_your_git_project (master *)
$ 

Tuesday, December 18, 2018

Inject git last commit id to SpringBoot project

1) Add git-commit-id-plugin in pom.xml

  <build>
  <plugins>
  <plugin>
      <groupId>pl.project13.maven</groupId>
      <artifactId>git-commit-id-plugin</artifactId>
      <executions>
          <execution>
              <goals>
                  <goal>revision</goal>
              </goals>
          </execution>
      </executions>
      <configuration>
          <dotGitDirectory>${project.basedir}/.git</dotGitDirectory>
          <includeOnlyProperties>
              <includeOnlyProperty>git.commit.id.abbrev</includeOnlyProperty>
          </includeOnlyProperties>
      </configuration>
  </plugin>
  ...
  </plugins>
  </build>


2) Get the value via Thymeleaf

   <head th:with="abbrev=${@environment.getProperty('git.commit.id.abbrev')}">

Tuesday, August 23, 2016

git commands

There are some useful git commands:

Setup a repository:

     git init --bare

Copy an existing repository:

     git clone drive:

Add file to repository:

     git add file
     git commit
     git push

Get updated files from repository:

     git fetch

Merge updated files to my workspace:

     git merge



CSP on Apache

To add CSP to root if sort of funny. The following will NOT work for most cases !!     <LocationMatch "^/$">        Header s...