title: Git Commands using powershell
body: <p>how to make the default directory of git as the location of the current powershell script</p>
  
  <p>this is the content of <strong>git-init.ps1</strong></p>
  
  <p>at <strong><em>C:/Users/MyUser/Desktop/Project101/git-init.ps1</em></strong></p>
  
  <p>and i want to initialize this path <strong><em>C:/Users/MyUser/Desktop/Project101/</em></strong></p>
  
  <p>but the problem is the git will initialize this path <strong><em>c:/Users/MyUser/.git</em></strong> i just followed the commands from Git Bash</p>
  
  <p>any help would be aprreciated. TIA</p>
  
  <pre><code>function run-git
  {
      # location of my installed git
      $x = Get-ChildItem env:LOCALAPPDATA | %{ $_.Value }
      $y = $x + "\Programs\Git\bin\sh.exe"
  
      # .$y --login -i -c "git init"
      # .$y --login -i -c "git remote add -t 'master' 'origin' 'E:/ProjectRepository/Project101'"
      # .$y --login -i -c "git pull"
  
      # get the location of this script
      $Invocation = (Get-Variable MyInvocation -Scope 1).Value
      $p = Split-Path $Invocation.MyCommand.Path
  
      .$y --login -i -c "cd $p"
      .$y --login -i -c "git init"
      # .$y --login -i -c "git init 'E:/WorkingDirectory'"
      .$y --login -i -c "git status"
  }
  
  run-git;
  </code></pre>