From this SO: How to recover a dropped stash in Git?
I would like to convert this Linux command to the Windows equivalent or maybe this is command is syntacially correct for Windows, not sure about the $ and the | :
gitk --all $( git fsck --no-reflog | awk '/dangling commit/ {print $3}' )
I have tried running this cmd on my Windows Git Shell, Powershell and Cmd.exe, with my cd being a git directory, with Cmd.exe:
On Git Shell:
Which gives me the following error:
I have installed gawk: http://gnuwin32.sourceforge.net/packages/gawk.htm
And added C:\Program Files (x86)\GnuWin32\bin to my Path Environment Variables
Here is the Windows PowerShell equivalent:
gitk --all $(git fsck --no-reflog | Select-String "(dangling commit )(.*)" | %{ $_.Line.Split(' ')[2] })
Ok so I had to install gawk/awk: http://gnuwin32.sourceforge.net/packages/gawk.htm
Then I updated my Path Environment Variable: C:\Program Files (x86)\GnuWin32\bin\
Then I had to restart my computer to refresh Environment Variables.
Then I could run the gitk cmd, without any changes, works fine on a Windows machine:
gitk --all $( git fsck --no-reflog | awk '/dangling commit/ {print $3}' )
But it has to be in Windows Git Shell, the cmd did not work from Windows cmd.exe.
Related
I am calling a python script from the job project> settings> build> run shell (bash).
The file I want to open in the script is not up to date, and Jenkins always remembers the old file I deleted in the script and Jenkins opens it.
I also found that the python delete command was not executed.
It looks like Jenkins is caching the initial file tree.
How can I always refer to the latest file tree?
Is there a command to clear the cache?
And how do I run the python delete command (os.remove(latest_sc_file))?
#!/bin/bash
echo "Python3 --version is: "`python3 --version`
# Python3 --version is: Python 3.5.2
echo "Python3 full-path is: "`which python3`
# Python3 full-path is: /usr/bin/python3
git checkout submit
# Check for added / changed files
for file in `git diff --name-only HEAD..origin/submit`
do
# echo $file
name=`echo $file | sed -r 's/.*submission_(.*).csv/\1/'`
echo "name: "$name
# pull submission.csv, test.csv
git pull origin submit:submit
# Start scoring
/home/kei/.pyenv/shims/python3 ./src/go/score.py $name linux > ./src/go/score.log 2>&1
done
The cause has been found.
It was because Jenkins wasn't caching it, but was downloading a remote file every time I git pulled it.
Therefore, I will withdraw this question.
If I run the command bellow and my install.sh has the following section:
export S3_URL=$PRD_URL
export S3_ACCESS_KEY=$PRD_S3_ACCESS_KEY
export S3_SECRET_KEY=$PRD_S3_SECRET_KEY
cat install.sh | ssh $PRD_USER#$PRD_HOST
The $PRD_S3_ACCESS_KEY is going to be resolved from my host or the environment variables from the remote server?
Assuming you have gettext installed (which contains envsubst), you can do
envsubst < install.sh | ssh $PRD_USER#$PRD_HOST
I've installed sublime text from bash but it doesn't work it just return the bash prompt again .
then
I installed sublime natively on windows , problem is I can't run it from bash .
It is already supported in Windows 10 latest build (build 14951), used like this:
$ export PATH=$PATH:/mnt/c/Windows/System32
$ notepad.exe
$ ipconfig.exe | grep IPv4 | cut -d: -f2
$ ls -la | findstr.exe foo.txt
$ cmd.exe /c dir
more information here.
There is a ticket about it in their Github page with some hacks you can use meanwhile.
It appears at this time, the cbwin project is our best bet. I just started running into these same issues with trying to use vagrant from Bash on Windows, and my vagrant install ran into issues that required kernel support (currently lacking in Bash on Windows).
Hi I have a shell script which contains s3cmd command on ubuntu 12.04 LTS.
I configured cron for this shell script which works fine for local environment but don't push the file to s3. But when i run shell script manually, It pushes the file to s3 without any error. I checked log and found nothing for this. Here is my shell script.
#!/bin/bash
User="abc"
datab="abc_xyz"
pass="abc#123"
Host="abc1db.instance.com"
FILE="abc_rds`date +%d_%b_%Y`.tar.gz"
S3_BKP_PATH="s3://abc/db/"
cd /abc/xyz/scripts/
mysqldump -u $User $datab -h $Host -p$pass | gzip -c > $FILE | tee -a /abc/xyz/logs/app-bkp.log
s3cmd --recursive put /abc/xyz/scripts/$FILE $S3_BKP_PATH | tee -a /abc/xyz/logs/app-bkp.log
mv /abc/xyz/scripts/$FILE /abc/xyz/backup2015/Database/
#END
This is really weird. Any suggestion would be a great help.
Check if the user running configured in crontab has correct permissions and keys in the environment.
I am guessing the keys are configured in env file as they are not here in the script.
anybody is familiar with the etcd project? Or we'd better forget the project when talk about this issue. The issue is
$ build
ln: `gopath/src/github.com/coreos/etcd': cannot overwrite directory
when exec the build shell
and the content is:
#!/bin/sh -e
if [ ! -h gopath/src/github.com/coreos/etcd ]; then
mkdir -p gopath/src/github.com/coreos/
ln -s ../../../.. gopath/src/github.com/coreos/etcd
fi
export GOBIN=${PWD}/bin
export GOPATH=${PWD}/gopath
export GOFMTPATH="./bench ./config ./discovery ./etcd ./error ./http ./log main.go ./metrics ./mod ./server ./store ./tests"
# Don't surprise user by formatting their codes by stealth
if [ "--fmt" = "$1" ]; then
gofmt -s -w -l $GOFMTPATH
fi
go install github.com/coreos/etcd
go install github.com/coreos/etcd/bench
Some addition:
My system is windows 7
I run the shell on git bash.
issue reproduce:
step1: open the git bash
step2: git clone git#github.com:coreos/etcd.git
step3: cd etcd
step4: build
As mentioned in "Git Bash Shell fails to create symbolic links" (since you are using the script in a git bash on Windows 7)
the ln that shipped with msysGit simply tries to copy its arguments, rather than fiddle with links. This is because links only work (sort of) on NTFS filesystems, and the MSYS team didn't want to reimplement ln.
A workaround is to run mklink from Bash.
This also allows you to create either a Symlink or a Junction.
So 'ln' wouldn't work as expected by default, in the old shell that ships with Git for Windows.
Here's solution. Tbh it is a workaround, but since you're on Windows, I don't see another way.
Start a command line, and enter there to the directory with the script. There should be a path gopath/src/github.com/coreos/ (if no such a path, you must create it). Next issue a command
mklink /D "gopath/src/github.com/coreos/etcd" "../../../../"
Next you should edit the build script to delete a lines with creation symlink and a directory. E.g.
#!/bin/sh -e
export GOBIN=${PWD}/bin
export GOPATH=${PWD}/gopath
export GOFMTPATH="./bench ./config ./discovery ./etcd ./error ./http ./log main.go ./metrics ./mod ./server ./store ./tests"
# Don't surprise user by formatting their codes by stealth
if [ "--fmt" = "$1" ]; then
gofmt -s -w -l $GOFMTPATH
fi
go install github.com/coreos/etcd
go install github.com/coreos/etcd/bench
Note, that I am just removed 4 lines of code. Next you run the script, and this should work.
You shouldn't be using git clone and the build sh script. Use the go get command. For example, on Windows 7,
Microsoft Windows [Version 6.1.7601]
C:\>set gopath
GOPATH=C:\gopath
C:\>go version
go version go1.3 windows/amd64
C:\>go get -v -u github.com/coreos/etcd
github.com/coreos/etcd (download)
github.com/coreos/etcd/third_party/bitbucket.org/kardianos/osext
github.com/coreos/etcd/pkg/strings
github.com/coreos/etcd/error
github.com/coreos/etcd/third_party/github.com/coreos/go-etcd/etcd
github.com/coreos/etcd/http
github.com/coreos/etcd/third_party/github.com/coreos/go-log/log
github.com/coreos/etcd/third_party/github.com/rcrowley/go-metrics
github.com/coreos/etcd/mod/dashboard/resources
github.com/coreos/etcd/log
github.com/coreos/etcd/third_party/github.com/gorilla/context
github.com/coreos/etcd/third_party/github.com/gorilla/mux
github.com/coreos/etcd/mod/dashboard
github.com/coreos/etcd/discovery
github.com/coreos/etcd/pkg/btrfs
github.com/coreos/etcd/pkg/http
github.com/coreos/etcd/third_party/code.google.com/p/gogoprotobuf/proto
github.com/coreos/etcd/mod/leader/v2
github.com/coreos/etcd/mod/lock/v2
github.com/coreos/etcd/metrics
github.com/coreos/etcd/third_party/github.com/mreiferson/go-httpclient
github.com/coreos/etcd/mod
github.com/coreos/etcd/third_party/github.com/BurntSushi/toml
github.com/coreos/etcd/third_party/github.com/goraft/raft/protobuf
github.com/coreos/etcd/third_party/github.com/goraft/raft
github.com/coreos/etcd/store
github.com/coreos/etcd/server/v1
github.com/coreos/etcd/server/v2
github.com/coreos/etcd/store/v2
github.com/coreos/etcd/server
github.com/coreos/etcd/config
github.com/coreos/etcd/etcd
github.com/coreos/etcd
C:\>