date int64 1,220B 1,719B | question_description stringlengths 28 29.9k | accepted_answer stringlengths 12 26.4k | question_title stringlengths 14 159 |
|---|---|---|---|
1,597,610,216,000 |
I added set -u (equiv. set -o nounset) to .bashrc, but now some tab autocompletes fail with errors about unset variables. One example is for git autocompletes.
Would this be a git autocomplete bug or is it generally a bad idea to use set -u in an interactive terminal? Is there an alternative way to protect myself from myself without breaking autocompletes?
(I have the same problem using "git bash" on Windows/cygwin, and with RHEL.)
|
set -u from the Bourne shell or its more explicit set -o nounset from the Korn shell (both are POSIX) is more of a programming tool, used to detect typos or use of initialised variables in your code.
That's a programming style choice. Once it's set, you can't have your code dereference unset variables, which means that you have to write your code differently.
For instance, you can't have:
if [ -n "$TERM" ]; then
echo running in a terminal
fi
You need to work around nounset with ${TERM-} in place of $TERM or use [[ -v TERM ]].
Some goes with most other options such as errexit or failglob or pipefail which change the way the shell works and for which code writers need to adapt their code.
Now, in interactive shells, that wouldn't be a problem if you were not using code written by others.
The problem is that bash doesn't have the equivalent of zsh's emulate -L where third party functions can explicitly request a local sane baseline of options for their own code.
In zsh, completion code usually does:
some-completion-function() {
emulate -L zsh # default set of options in the zsh emulation set locally
set -o extendedglob -o errreturn # additional local options as needed
code here not impacted by the users options
}
There's no equivalent in bash and while recent versions of bash have local - (from ash) to set a local scope for the options set by set, there's no equivalent for the options set by shopt. And as there's no equivalent of emulate, you'd need to hardcode all the options to their default value the list of which varies with the bash version.
Worth, the bash_completion (which is a separate project independent from bash itself) changes the options from the default globally (not only for itself) and expects you not to change it. For instance, it sets extglob and progcomp.
You'll find that it sometimes sets options temporarily such as verbose, noglob or nullglob clunkily by saving the old setting in a variable and restoring afterwards.
In both bash and zsh, there are even options that affect the way code is parsed, so those should be set after the completion code (or any third party code) is loaded. In zsh, most of the completion code is autoloaded on first use, and the autoloading can be done independently of the user's options or aliases (-z and -U options of autoload), but again there's no equivalent in bash.
So you'll find that there are a lot of options which once changed from their default value cause the bash completion to fail (noglob, nounset, errexit, errreturn, failglob and probably more). Changing the $IFS value IIRC causes problems as well (or at least used to). While some of those may be considered as bugs of bash_completion, in most cases, you can't really blame them as the problem is that bash has no facility to cope with requirements for different sets of options.
So if you're changing the options, be ready for some third party code you use in your shell to fail.
| Should I use `set -u` in my terminal? Why does it break autocomplete for git? |
1,597,610,216,000 |
How can git diff color be changed to one's disposal, or such as for diff ...?
in ~/.gitconfig:
[color "diff"]
added = yellow
changed = red bold
not work.
Please sincere help appreciated
|
The git-config(1) manual details the available slots; your added and changed might work instead as new and old.
color.diff.<slot>
Use customized color for diff colorization. <slot> specifies which
part of the patch to use the specified color, and is one of context
(context text - plain is a historical synonym), meta
(metainformation), frag (hunk header), func (function in hunk
header), old (removed lines), new (added lines), commit (commit
headers), whitespace (highlighting whitespace errors), oldMoved
(deleted lines), newMoved (added lines), oldMovedDimmed,
oldMovedAlternative, oldMovedAlternativeDimmed, newMovedDimmed,
newMovedAlternative newMovedAlternativeDimmed (See the <mode>
setting of --color-moved in git-diff(1) for details),
contextDimmed, oldDimmed, newDimmed, contextBold, oldBold, and
newBold (see git-range-diff(1) for details).
| Have git diff color customization |
1,597,610,216,000 |
I wish to detect if a staged file has unstaged changes, and add this to a pre-commit hook.
For example, when the output is like this, I should be able to detect that README.md has unstaged changes.
❯ git status
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
modified: README.md
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: README.md
modified: foo.txt
The best solution I could find is to write the list of staged and unstaged files into files, and use comm
git diff --name-only > /tmp/unstaged.txt
git diff --name-only --staged > /tmp/staged.txt
comm /tmp/unstaged.txt /tmp/staged.txt
|
If you use short status, staged content shows up as M in the first column, non-staged content as M in the second column. Thus detecting files with staged and non-staged changes can be done with
git status -s | awk '/MM / { print $2 }'
| Git - find staged files with unstaged changes |
1,597,610,216,000 |
Say, I create a new repo, and try to commit. Git shows me
*** Please tell me who you are.
Run
git config --global user.email "[email protected]"
git config --global user.name "Your Name"
to set your account's default identity.
Omit --global to set the identity only in this repository.
Without reading the last line, I run the two lines suggested by git (with --global) and happily commit.
A week later I create a new repo for a completely unrelated project where I'd need to commit under a different user.email. Without even thinking about user.email, I try to commit, it goes through and I push to the origin.
The above happened to me twice and made me think whether there is a way to disallow git config --global.
For example, if I run
git config --global user.email "[email protected]"
I'd like bash not to run the command and show me a warning, but when I run
git config user.email "[email protected]"
I'd like it to go through.
Is it possible?
|
Simplest is to make a function for this one case (for Bash):
git() {
for arg in "$@"; do
if [[ $arg == --global ]]; then
echo "Don't use '--global'!"
return 1
fi
done
command git "$@"
}
Note that that wouldn't check if --global there is actually an option, and not e.g. an option-argument to another option and wouldn't matter in the least if git is run from somewhere other than the shell. Also if you make a git alias to include --global, it won't be caught by this, etc. Obviously you can also circumvent the protection by running command git or /usr/bin/git, or by just undefining the function.
| Is there a way to disallow a certain combination of commands and options? |
1,597,610,216,000 |
This is similar to the question about http not supported, but I was not able to apply the solutions suggested there to my situation.
I've done
zypper addrepo https://download.opensuse.org/repositories/devel:tools:scm/SLE_12_SP5/devel:tools:scm.repo
zypper refresh
and I'm getting
Retrieving repository 'Software configuration management (SLE_12_SP5)' met
Download (curl) error for 'https://download.opensuse.org/repositories/devels:/scm/SLE_12_SP5/repodata/8ff6d5e77f953a771c9870113c655dfef8cf31ffba709feec8e0a617fc-primary.xml.gz':
Error code: Bad URL
Error message: Redirect to protocol "http" not supported or disabled in li
Now if I
curl https://download.opensuse.org/repositories/devel:/tools:/scm/SLE_12_SP5/repodata/8ff6d5e77f953a771c9870113c655dfef8cf31ffba709f2506cceec8e0a617fc-primary.xml.gz
I see
<p>The document has moved <a href="http://downloadcontent.opensuse.org/repositories/devel:/tools:/scm/SLE_12_SP5/repodata/8ff6d5e77f953a771c9870113c655dfef8cf31ffba709f2506cceec8e0a617fc-primary.xml.gz">here</a>.</p>
But if I try to apply the solution suggested in the related question with a
vi /etc/zypp/repos.d/devel_tools_scm.repo
and I change https in http, then it does not work because the http URL does (no longer?) exist: http://download.opensuse.org/repositories/devel:/languages:/php/openSUSE_Leap_42.3/devel:languages:php.repo
What am I doing wrong or what am I supposed to do to install git so?
|
As you've indicated that what I mentioned in my comment worked after you tried it, I'm going to post it as an answer:
zypper install git
git is available in the SLES repos as it is in the repos for nearly every other distribution. In the case of SLES, the above command will install it as long as the repos are enabled.
| How to install git on SLES 12? |
1,597,610,216,000 |
Is there an existing tool which will do something like this:
git-cat https://github.com/AbhishekSinhaCoder/Collection-of-Useful-Scripts
then it will run cat on each file in the repo?
Something like this works but it doesn't separate the files:
curl -s -H "Accept:application/vnd.github.v3.raw" https://api.github.com/repos/AbhishekSinhaCoder/Collection-of-Useful-Scripts/contents/ |
jq .[].download_url -r |
xargs curl 2>/dev/null |
bat
|
This is possible with a small modification to your command line:
curl -s -H "Accept:application/vnd.github.v3.raw" https://api.github.com/repos/AbhishekSinhaCoder/Collection-of-Useful-Scripts/contents/ |
jq .[].download_url -r |
xargs -L1 sh -c 'curl "$0" 2>/dev/null | bat'
Having said that, if there are a large number of files, you may end up getting rate-limited due to making too many requests, or your results may end up incomplete because they're paginated. You may wish to do a shallow clone (git clone --depth=1) or a partial clone (git clone --filter=blob:none) if you'd rather not have the expense of a full clone.
| Cat all the files in a git repo without cloning |
1,597,610,216,000 |
I am writing a software. For my work I need to connect to the common git repository, when I turned out that the necessary packages are not installed on my computer. Is it enough to install a single git package into the system?
$ sudo yum -y install git
Or does it require something more?
|
On CentOS,
sudo yum -y install git
is indeed enough to install git.
| Installation of git in CentOS |
1,597,610,216,000 |
I want to set up a server that hosts git repositories over ssh and https with client certificates. I don't want any snazzy GUI or anything like that (i.e. not Bitbucket, GitLab, etc) I want a bare minimum configuration for hosting repositories only.
However, I do want user separation between repositories.
I already have a solution for the https case, and I have an annoying solution for ssh.
I did some searches for multi-user ssh git server configurations, but the base assumptions for the guides I found was that all users have access to all the repositories. I.e. create a "git" user, add all the users' public keys to ~git/.ssh/authorized_keys, use git-shell for the "git" user and host all the repos under the "git" user.
What I want to accomplish is to host a bunch of repositories which - by default - users can not access until given explicit permission to do so by having an administrator adding their ssh key to a project.
I have previously accomplished this by assigning each user a different account in the system, and use regular group permissions to do the sharing -- but this is cumbersome for a few reasons.
What's the general theory behind getting this feature to work smoothly?
I assume that the basic idea is to have a single "git" user and have each user in the ~git/authorized_keys, but once ssh has authenticated it passes on information about the authentication to some external user database containing all the repo permissions which is then used to perform file system access checks as appropriate.
|
I did this a few years back for SVN. I set up one Unix account. i.e. git@
Added user keys to ~git/authorized_keys, with the extra stuff to run the server (i.e. git-shell) when the user logs in.
So far exactly what you said in paragraph 4.
The bit that you are missing is that each entry in ~git/authorized_keys passes a different argument to git-shell telling it the name of the user. git-shell should then act accordingly to separate users. That is it has its own idea of users.
| Setting up a git server with ssh access |
1,597,610,216,000 |
My organization gives me no access to root and has some very weird authentication that is explained below:
I login to the RHEL server using my username and password combination via ssh terminal
I am not allowed to use my account and must switch to the server account using the following command: sudo su - appuser
any permutation to the command above is not allowed. Meaning sudo su -p appuser is not allowed sudo su appuser is not allowed. IT MUST BE sudo su - appuser. I get to enter my password before I switch to appuser
now I am in the appuser which does not have sudo rights.. I do my work now.
recently I started using git and in git you can specify username and password. Well, if my team of 6 people use it, they will all have the same username.
unless they run the following command line to get their real username after they switch to the appuser: git config --global user.name $(logname)
So, I am trying to navigate this poor infrastructure that I do not have control over by making a script that will allow me to switch user and set my git user immediately after I switch to the appuser.
What I currently have is this (which does not work because I get asked for the password because of line 1):
sudo su - appuser
git config --global user.email $(logname)
What are my options other than going to IT and asking for a solution that I know they will not provide?
|
You can set environment variables based on your logname:
case $logname in
shnisaka)
export GIT_AUTHOR_NAME="your name"
export GIT_COMMITTER_NAME="your name"
export GIT_AUTHOR_EMAIL="[email protected]"
export GIT_COMMITTER_EMAIL="[email protected]"
;;
olqs)
export GIT_AUTHOR_NAME="my name"
export GIT_COMMITTER_NAME="my name"
export GIT_AUTHOR_EMAIL="[email protected]"
export GIT_COMMITTER_EMAIL="[email protected]"
;;
esac
We have a similar config in our profile settings. Try to put it in the .bashrc of appuser
| shell script to run commands after sudo su - appuser |
1,597,610,216,000 |
I wrote myself a pretty, git aware ksh prompt function. Here I only include a minimal working example so that you can see my problem without all the bloat:
#!/bin/ksh
function _test_prompt
{
prompt="`whoami`@`hostname` > "
[[ $(id -u) -eq 0 ]] && prompt="ROOT@`hostname` # "
print "\n\w"
print -n "$prompt"
}
export readonly PS1='$(_test_prompt)'
I source this script from my .kshrc.
The problem is that when I try to look at for example a longer, prettified git log, the prompt's newlines cut off the top of my output. For example
git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s'
shows up as
* f0490d0 - Make sure fb is big enough to handle reconfigure (3 years, 10 months ago) <Keith Packard>
* 7caa6ce - Add xrandr-auto sample script (3 years, 10 months ago) <Keith Packard>
* f59c924 - (tag: v0.2) Update to version 0.2 (7 years ago) <Keith Packard>
* a6c8969 - Add --auto switch, a shortcut for --config "xrandr --auto" (7 years ago) <Keith Packard>
* d45135b - Add manual (7 years ago) <Keith Packard>
* ef165dc - add .gitignore (7 years ago) <Keith Packard>
* d927ec1 - Autotool (7 years ago) <Keith Packard>
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~/git-misc/x-on-resize
user@hostname >
And the first line of the output can only be seen by paging up once:
~/git-misc/x-on-resize
user@hostname > git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s'
* 617e5ed - (HEAD -> master, origin/master, origin/HEAD) Use mode ID instead of mode for autoconfig (3 years, 10 months ago) <Keith Packard>
* f0490d0 - Make sure fb is big enough to handle reconfigure (3 years, 10 months ago) <Keith Packard>
(this is what's at the bottom of the previous page, cut off).
As you can imagine, this is very annoying; in this case I actually lose the most recent commit and have to scroll up for it.
This only happens when the output of the log would fit on one screen (otherwise it goes into less).
Thanks for your help!
|
As usual, I managed to solve the problem after I actually got around to ask about it.
I simply set the pager.log git config variable to less -RFc; the relevant switch is -c as far as I understand: it tells less to repaint the screen from bottom to top instead of doing so vice versa.
Apprently, this was indeed not a ksh issue. My apologies.
| ksh prompt defined as function with newlines |
1,597,610,216,000 |
Recently we have been seeing a lot of connections from IPs in to our public git server. When this happens, our devs are unable to commit via SSH as the server is very, very slow and I am unable to login via SSH remotely and have to login from the console to resolve the issue. HTTPs to gitlab still works when this happens. System resources are plentiful and I have edited sshd_config to block all port 22 access unless they have a key. I also have IPS setup to block multiple SSH attempts and have fail2ban on the server.
With all that setup, I am unsure how this is creating such an issue for the server. I can resolve the issues by restarting the sshd service and blocking the offending subnets, but why is it messing up SSH so much that it makes the server unusable via SSH? Are all of these attempts somehow using all of the ports and therefore blocking legit access attempts? Below is a copy of the secure log file with an attempt. Note, there is a big time gap from 14:30:18 to 14:30:50.
Sep 4 14:30:17 somegitserver sshd[5924]: Connection from 11.11.11.11 port 62290
Sep 4 14:30:17 somegitserver sshd[5924]: debug1: Client protocol version 2.0; client software version libssh-0.11
Sep 4 14:30:17 somegitserver sshd[5924]: debug1: no match: libssh-0.11
Sep 4 14:30:17 somegitserver sshd[5924]: debug1: Enabling compatibility mode for protocol 2.0
Sep 4 14:30:17 somegitserver sshd[5924]: debug1: Local version string SSH-2.0-OpenSSH_5.3
Sep 4 14:30:17 somegitserver sshd[5941]: debug1: permanently_set_uid: 74/74
Sep 4 14:30:17 somegitserver sshd[5941]: debug1: list_hostkey_types: ssh-rsa,ssh-dss
Sep 4 14:30:17 somegitserver sshd[5941]: debug1: SSH2_MSG_KEXINIT sent
Sep 4 14:30:17 somegitserver sshd[5941]: debug1: SSH2_MSG_KEXINIT received
Sep 4 14:30:17 somegitserver sshd[5941]: debug1: kex: client->server aes128-cbc hmac-sha1 none
Sep 4 14:30:17 somegitserver sshd[5941]: debug1: kex: server->client aes128-cbc hmac-sha1 none
Sep 4 14:30:17 somegitserver sshd[5941]: debug1: expecting SSH2_MSG_KEXDH_INIT
Sep 4 14:30:18 somegitserver sshd[5941]: debug1: SSH2_MSG_NEWKEYS sent
Sep 4 14:30:18 somegitserver sshd[5941]: debug1: expecting SSH2_MSG_NEWKEYS
Sep 4 14:30:18 somegitserver sshd[5941]: debug1: SSH2_MSG_NEWKEYS received
Sep 4 14:30:18 somegitserver sshd[5941]: debug1: KEX done
Sep 4 14:30:18 somegitserver sshd[5941]: debug1: userauth-request for user root service ssh-connection method keyboard-interactive
Sep 4 14:30:50 somegitserver sshd[5944]: debug1: Enabling compatibility mode for protocol 2.0
Sep 4 14:30:51 somegitserver sshd[5941]: debug1: do_cleanup
Sep 4 14:30:51 somegitserver sshd[5945]: debug1: rexec start in 5 out 5 newsock 5 pipe 10 sock 11
Sep 4 14:30:51 somegitserver sshd[5944]: debug1: Local version string SSH-2.0-OpenSSH_5.3
Sep 4 14:30:51 somegitserver sshd[5924]: debug1: do_cleanup
Sep 4 14:30:51 somegitserver sshd[5945]: debug1: inetd sockets after dupping: 3, 3
Sep 4 14:30:51 somegitserver sshd[5961]: debug1: permanently_set_uid: 74/74
Sep 4 14:30:51 somegitserver sshd[5924]: debug1: PAM: cleanup
What am I missing?
|
The issue was with my fail2ban config not reading the correct log file. Once I updated my jail.local file and specified /var/log/secure instead of /var/log/sshd.log, I was starting to see IPs go in to the jail. This had fail2ban working but it still wasn't blocking certain log entries. I wanted to block specific entries that contained 11: Bye Bye but my custom filter in fail2ban was not working: ^%(__prefix_line)sReceived disconnect from <HOST>: 11: \S+: *$
To completely resolve my issue, I found that version 0.10.5.dev1 of fail2ban could catch that specific entry in the log file by default. I upgraded and redid the config and it is now working as I hoped.
| Bulk login attempts on port 22 shutdown our SSH git server access, HTTPs still works though |
1,597,610,216,000 |
I am using Ubuntu 16.04. I have a directory named Work which I want to backup to github everytime I poweroff my computer.
I have written the backup script and it's working fine but I cannot run it before shutting down. Please help.
Here are the contents of backup_work.sh
cd /home/kaustab/Work
git add .
git commit -m "Daily Backup"
mkdir /home/kaustab/test
git push origin master
echo "Backed up"
read -n 1 -s -r -p "Press any key to continue"
|
Thank you all for all your help but I have managed to solve this.
What I did was edit the shutdown.desktop in /usr/share/applications and changed the exec to my script. This is what my modified shutdown.desktop file looks like.
[Desktop Entry]
Name=Shutdown
Comment=Backup and power off the computer
GenericName=Shut Down
Exec=gnome-terminal -e /home/kaustab/.scripts/backup_work.sh
Terminal=false
Type=Application
Categories=Utility
Icon=/usr/share/unity/icons/shutdown_highlight.png
NotShowIn=GNOME-Flashback;
X-AppStream-Ignore=true
X-Ubuntu-Gettext-Domain=session-shortcuts
At the end of the backup_work.sh script I have added the line gnome-session-quit --power-off to give me the options of the power menu.
Thanks to QIS for pointing out to use ssh instead of https to connect to github. I will be trying that later.
| Backup Work dir to git before shutdown |
1,597,610,216,000 |
I am working on making a git command I use more useful. A common task I do is to grep my git rev-list --all. I wrote (aka cut and pasted another StackExchange answer) git command to do this for me.
~/bin/git-search:
!/bin/bash
function _search() {
git rev-list --all | (
while read revision; do
git grep -F $1 $revision
done
)
}
_search $1
The output from this looks like:
f26ce56cf6b17401292c494f906b2b6a9071ca75:filename.py:grepped string
I usually take these results and run git show along with the commit and file path to see that particular version of the file. git show takes the input of {COMMIT HASH}:path/to/file.
What I'd ideally like is to have my git function stick a whitespace where the second : is, which would allow me more easily copy and paste the output of git-search into git show, ie:
f26ce56cf6b17401292c494f906b2b6a9071ca75:filename.py grepped string
I'd like to use BASH for this as I am already using BASH. My initial solution was to use Python but that seems needless to me. I just am not sure how best to achieve this in BASH.
|
sed 's/:/ /2'
This would change the second : character to a space.
You could stick that in as an extra stage of your function's pipeline:
#!/bin/sh
git rev-list --all |
while read revision; do
git grep -F "$1" "$revision"
done |
sed 's/:/ /2'
(I actually deleted the function as it didn't seem to be needed; note also the quoting of the variable expansions; oh, and it's a /bin/sh script since it's not using any bash-specific features (neither did yours, except for the unneeded function keyword))
| Remove the second instance of a character from a string |
1,597,610,216,000 |
I have a problem with gpg2 and signing my commits in git. I should preface all this by saying this all worked yesterday before I did an apt-get update && apt-get upgrade and a reboot.
Now when I try to sign my commits I get the following error message:
gpg: skipped "3C27FEA3B5758D9E": No secret key
gpg: signing failed: No secret key
error: gpg failed to sign the data
fatal: failed to write commit object
Actually, I seem to get it when I try to stash my changes too.
When I do a pgrep I can see that gpg-agent is running so I've killed it and restarted it.
I have also have this in my .bashrc file:
export GPG_TTY=$(tty)
Output of gpg2 --list-keys /home/mdhas/.gnupg/pubring.gpg:
------------------------------
pub rsa2048/FBJJJJ1C 2017-10-11 [SC]
uid [ultimate] Mark Dhas <[email protected]>
sub rsa2048/3FDJJJJJ 2017-10-11 [E]
pub rsa2048/BFJJJJJ7 2017-11-17 [SC]
uid [ultimate] Mark Dhas <[email protected]>
sub rsa2048/DEDDJJJJ 2017-11-17 [E]
pub rsa4096/7137JJJJ 2017-10-11 [SC] [expires: 2021-10-11]
uid [ unknown] co.co <[email protected]>
sub rsa4096/A9BJJJJJ 2017-10-11 [E] [expires: 2021-10-11]
pub rsa4096/B57JJJJJ 2018-10-31 [SC] [expires: 2021-10-31]
uid [ unknown] Mark Dhas (New Key-Created on 2018-10-31) <[email protected]>
sub rsa4096/36FJJJJJ 2018-10-31 [E] [expires: 2021-10-31]
Please ignore the JJJJJ's they are an attempt at a small amount of redaction for security purposes.
$ gpg2 --list-secret-keys
/home/mdhas/.gnupg/pubring.gpg
------------------------------
sec rsa2048/FBJJJJ1C 2017-10-11 [SC]
uid [ultimate] Mark Dhas <[email protected]>
ssb rsa2048/3FDJJJJJ 2017-10-11 [E]
And this is a section of my git config
user.name=Mark Dhas
[email protected]
user.signingkey=3C2JJJJJJJJJJJJJ
core.editor=vim
gpg.program=/usr/bin/gpg2
Any ideas on how to rectify this issue would be great.
|
You don't have the private part of your GPG key. A GPG key consists of a public key, the piece of information that other computers can use to verify signatures coming from you, and the private key, the part that is needed to create a signature or decrypt messages sent to you. This is why Git is giving you an error. It can't get the private key to sign the commit. Your only option is to find a backup of the entire key (one that includes the private key), or to create a new key.
| gpg2 and git signing |
1,597,610,216,000 |
I use the "gogs" self-hosted git service, but I want to change to a more active fork called gitea. The installation instructions say I should create a user (e.g. git) dedicated for use by gitea:
adduser \
--system \
--shell /bin/bash \
--gecos 'Git Version Control' \
--group \
--disabled-password \
--home /home/git \
git
I currently use gogs in windows, without a special user. Now I want to use gitea in linux, hence my confusion - I assume it's because I might not understand daemons in general.
In windows, when I want to start the service, I run it, and it stays open either in a terminal window or as a background service, until I stop it. In linux I can do the same, so why do I need a dedicated user?
I assume the same practice is used for other services as well, so I need to understand the implications of using / not using a dedicated user for a service.
(I guess this is related to running a service without a user logging on and starting it. But lots of other services are already running and they do not need dedicated users, do they?)
|
Your confusion stems from the fact that you do not understand what you are doing on Windows. On Windows, actual services are run from the Service Control Manager, and they have had the ability to run under the aegides of dedicated user accounts all along. A proper unprivileged service on Windows employs the username of a dedicated unprivileged user account, which the SCM logs in as in order to create the service process.
What you are doing, in contrast, is not running a service at all. You are running a program in your interactive logon session, in the background. And it isn't a terminal that you are using, it is a console.
The reasons for employing dedicated accounts for services are in fact common to Windows and Linux operating systems. Running services as separate processes under the aegides of dedicated accounts means that the operating system mechanisms that protect users from one another (Windows NT and Linux both being multi-user from the ground up, remember) also protect the service processes from you, an interactive user, and from other services. They likewise protect you and those other services from the service.
The multi-user mechanisms allow find grained access control on files and directories that the service program uses, prevent the services from being sent arbitrary signals by malicious processes, prevent the service processes from being traced using the debug APIs, prevent thread injection, and prevent arbitrary processes from being able to pause and resume threads. And all of these preventions work the other way, too, meaning that the service, should it be compromised, cannot do these things to others.
You are running a service that responds to requests across the network. It is designed to run under the aegis of a dedicated user account for these very reasons. It speaks a complex human-readable protocol that is non-trivial for programs to parse correctly, and could potentially be compromised if there were an error somewhere in that parser. But any attacker that succeeds in compromising it only gains access to your system as that dedicated service user, which you should have ensured has no unnecessary access to, or ownership of, files and directories that are not part of its intended function.
I myself extend this to the logging as well. Individual log services run with only the privileges necessary to access and write to their specific log directories, and are insulated from one another, from interactive users, and even from the (unprivileged) "main" services whose logs they are writing.
In a well-architected system, there should be scant few service processes that run with privileged access. Generally, they will be things that provide some sort of multi-user login, such as SSH or FTP services, where the major part of the service does still in fact run under the aegis of an unprivileged account; but it is simply the case that negotiating which account is an inherent part of the service function.
As such, you should now be thinking whether the gitea instructions are enough. The service account that you are creating is permitted interactive login via SSH, has an interactive shell program as its login program, and owns a home directory, giving a compromised service the ability to put stuff there and grant access to stuff there.
Further reading
Jonathan de Boyne Pollard (2018). "Introduction". nosh Guide. Softwares.
Jonathan de Boyne Pollard (2018). "Log service security: Dedicated log user accounts". nosh Guide. Softwares.
Jonathan de Boyne Pollard (2018). "Limiting services: Running under the aegises of unprivileged user accounts". nosh Guide. Softwares.
"Service User Accounts". Windows desktop: System Services. MSDN. Microsoft.
"Setting up a Service's User Account". Windows desktop: Active Directory Domain Services. MSDN. Microsoft.
Daniel J. Bernstein. The qmail security guarantee. cr.yp.to.
Jonathan de Boyne Pollard (2011). The console and terminal paradigms for TUIs. Frequently Given Answers.
https://unix.stackexchange.com/a/198713/5132
https://unix.stackexchange.com/a/447329/5132
| Why do I need a dedicated user for a service (my git service: gogs / gitea)? [duplicate] |
1,597,610,216,000 |
i am trying to restrict users to give an unformatted message in git commit-message window. For that i created some formatted regex and trying to put that one in commit-msg hook.
But i am unable to compare the git commit-message string with below regex.
Could you please help me to resolve this ?
regex="[A-Z]{3,}-[0-9][0-9]* #time (?:[0-9]+[wdhm])+ #comment (.|\n)*"
file=`cat $1`
echo $regex
echo $file
if [[ "$file" =~ $regex ]]; then
echo "Valid date"
else
echo "Pre-Commit hook is failed. commit-message format not met regex pattern Eg: TEST-123 #time 2w #comment added second line"
exit 1
fi
|
(?:...) is a perl regexp operator. If you want to use those in a shell, you need zsh or ksh93. bash has no support for them. Anyway here, the standard ERE (...) could be used instead.
What \n matches is also unspecified in POSIX extended regexp which bash uses (on most systems, it will match on n only) but note that anyway . also matches on the newline character in EREs
anyway, regexps are not anchored in the [[ ... =~ ... ]] operator, so any <anything>* at the end would be redundant as it's sure to match as it matches at least the empty string.
what [A-Z] matches outside of the POSIX locale is pretty random in practice. It will likely match on the 26 uppercase letters of the English alphabet, but probably a lot more characters (even possibly sequences of characters)¹
Same for [0-9] which depending on the locale and the system matches on decimal digits and possibly more random characters.
unquoted parameter expansions has a very special meaning in shells, there's no reason you'd want to keep those $1/$regex... unquoted there.
When passing arbitrary arguments to commands, you need to make sure they are not treated as options. So file=$(cat -- "$1") or file=$(cat < "$1") or with ksh/zsh/bash: file=$(<"$1") (though it may fail to return a non-zero exit status upon failure).
echo can't be used for arbitrary data
it's a good idea to check for the success/failure of a command before carrying on to the next.
errors should generally go to stderr.
uppercase=ABCDEFGHIJKLMNOPQRSTUVWXYZ
digit=0123456789
regexp="^[$uppercase]{3,}-[$digit]+ #time ([$digit]+[wdhm])+ #comment "
file=$(cat < "$1") || exit
printf '%s\n' "regexp: $regexp" "file: $file"
if [[ "$file" =~ $regexp ]]; then
echo valid
else
echo >&2 invalid
exit 1
fi
A few extra notes:
command substitution $(cat < "$1") above strips all trailing newline characters. So would remove trailing empty lines from the content of the file.
bash contrary to zsh can't store the NUL character in its variables. If the input file contains some, they will be discarded (Which is probably just as well) with a warning message.
¹ On my GNU system, in a en_GB.UTF-8 locale (typical in Britain), it matches on at least ABCDEFGHIJKLMNOPQRSTUVWXYZÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝĀĂĄĆĈĊČĎĐĒĔĖĘĚĜĞĠĢĤĦĨĪĬĮİIJĴĶĹĻĽĿŁŃŅŇŊŌŎŐŒŔŖŘŚŜŞŠŢŤŦŨŪŬŮŰŲŴŶŸƁƆƇƊƎƏƐƓƘƟƠƢƯƳDŽDžLJLjNJNjǍǏǑǓǕǗǙǛǞǠǢǤǦǨǪǬDZDzǴǶǷǸǺǼǾȀȂȄȆȈȊȌȎȐȒȘȚȜȞȦȨȪȬȮȰȲḀḂḄḆḈḊḌḎḐḒḔḖḘḚḜḞḠḢḤḦḨḪḬḮḰḲḴḶḸḺḼḾṀṂṄṆṈṊṌṎṐṒṔṖṘṚṜṞṠṢṤṦṨṪṬṮṰṲṴṶṸṺṼṾẀẂẄẆẈẊẌẎẠẢẤẦẨẪẬẮẰẲẴẶẸẺẼẾỀỂỄỆỈỊỌỎỐỒỔỖỘỚỜỞỠỢỤỦỨỪỬỮỰỲỴỶỸ
| Unable to compare string with regex using test operator in shell script |
1,597,610,216,000 |
I work with many large files (~0.5-1TB) on a server. I would like a better way to do version tracking of these files on the server.
My limited understanding is that this may be possible with git LFS. I wouldn't actually be storing files, but rather using the storage that already exists.
Linux (or other OS) does keep track of the timestamp when I last accessed the files. But I would like to have more of a message, e.g. "I changed this data because XYZ" today (similar to 'git commit').
Is this a reasonable task for Git LFS? Or is this regular Git? (Also, is there another solution to version tracking in this case?)
|
Have you used git-annex?
https://git-annex.branchable.com/
git-annex allows managing files with git, without checking the file contents into git. While that may seem paradoxical, it is useful when dealing with files larger than git can currently easily handle, whether due to limitations in memory, time, or disk space.
Git annex can manage a repo between multiple remotes and has different modes for each (client,transfer,backup,full backup and more). It also has an easier web interface, but you'll have to use the CLI often.
After you add files with git annex add ., it moves them to .git/annex/objects and replcaes all the files by symlinks. Then you can acquire/remove them (from the same computer or another remote) with get and drop, respectively. Committing them to the repo works exactly like a normal git repo but git-annex takes care of the files.
It's a barebones personal cloud storage solution.
| Git and Git LFS: Doing version tracking on files via a server |
1,597,610,216,000 |
git will color it's output. Staged changes are green and deleted files are red for example.
I have a script running several git commands in parallel and I use sponge to get a nicer output.
But using sponge removes the colors, is there a way to change that?
|
Now that I knew what to look for, I found the answer on Stack Overflow:
git -c color.ui=always -c color.status=always status | sponge
| Colored git output piped to sponge |
1,597,610,216,000 |
I am studying my listening services, and I am thinking how identify the type of git listening services so I can kill git the right one in the right situation and/or both.
The services are needed for git push and git pull or git clone [repos], working also for a git server (DopeGhoti).
Code where I do not understand what each listening service is doing
masi@masi:~$ netstat -lt
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 *:git *:* LISTEN
tcp6 0 0 [::]:git [::]:* LISTEN
Doing netstat -plnt but how to determine which belongs to Git A or B service
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:5348 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:17991 0.0.0.0:* LISTEN 24698/rsession
tcp 0 0 0.0.0.0:9418 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:34893 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:9999 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN -
tcp6 0 0 :::9418 :::* LISTEN -
tcp6 0 0 :::9999 :::* LISTEN -
tcp6 0 0 :::111 :::* LISTEN -
tcp6 0 0 :::80 :::* LISTEN -
tcp6 0 0 :::33875 :::* LISTEN -
tcp6 0 0 ::1:631 :::* LISTEN -
tcp6 0 0 ::1:5432 :::* LISTEN -
tcp6 0 0 ::1:25 :::* LISTEN -
OS: Debian 8.7
Git: 2.1.4
|
"So many of them?" It's using precisely one, albeit on both the IPv4 and IPv6 interfaces.
Any service needs to be listening (or have a service aggregator such as xinetd listen by proxy) to some port or socket in order for incoming connections to be accepted.
In /etc/services, you can see git's port, 9418:
git 9418/tcp # Git Version Control System
| How to identify and kill git listening services here? |
1,597,610,216,000 |
I want an alias shortcut to achieve the following:
Clone a github repository with a custom folder name
Open it in my fav text editor (atom)
I currently use this inside ~/.zshrc:
alias quickstart="git clone https://github.com/myname/quickstart-html-template.git new_html_project && atom new_html_project"
Can I parameterize new_html_project?
|
You can't define parameters in an alias, you need to use a function:
quickstart() {
git clone https://github.com/myname/quickstart-html-template.git "$1" && atom "$1"
}
Add that to your .zshrc instead of the alias definition.
| Using zsh alias to quickly clone a git repository with custom folder name |
1,597,610,216,000 |
The git(1) manual page says:
See gittutorial(7) to get started, then see Everyday Git[1]
for a useful minimum set of commands. The Git User’s Manual[2]
has a more in-depth introduction.
Where is either "Everyday Git[1]" or "Git User's Manual[2]"?
|
The links can be found at the very end of the man page:
1. Git User’s Manual
file:///usr/local/share/doc/git/user-manual.html
2. Git concepts chapter of the user-manual
file:///usr/local/share/doc/git/user-manual.html#git-concepts
3. howto
file:///usr/local/share/doc/git/howto-index.html
4. Git API documentation
file:///usr/local/share/doc/git/technical/api-index.html
5. [email protected]
mailto:[email protected]
The [number] notation usually means that it references some document, and at the end of (page,document,...) you can find location of these documents. I encourage you to look around more before asking the question ;)
| How could I find those git documents('Everyday Git[1]' & 'Git User's Manual[2]') mentioned in the man pages? |
1,372,926,892,000 |
I have gitolite on a Centos 5.5 box - when a repository is updated, I need to send a command to my bug tracking appliance to get the new commands. Right now, I have the following command working:
ssh bugserver -f 'cd /etc/repos/gitrepo && git pull origin prod && exit'
This seems a little dirty, though. Is there a better way to execute this sync?
|
After considering the options, I decided to modify the command (removed the && exit) and left it as is for simplicity.
| What is the proper way to automate SSH/local command? |
1,372,926,892,000 |
I would like to use the code stored in an external git repository (I mean I am not a contributor for this code, I cannot push or create branches) but of course I need to change some files before compile it (for example for path, options, etc).
My question is: could you propose me a workflow to keep track of (only) my own slight changes in git.
duplicate the repo: first, it's not very nice for the developers, then difficult to follow evolutions of the origin repository
fork: there is no reason to do a fork as my changes are minor and do not constitute any real contribution to the project (who cares about the paths on my disk, and the options I used at a time).
To illustrate my question, for example imagine I git clone recipes to build a linux kernel. I want to keep track of the different options and modules I included... And if the origin linux kernel evolves I would like to be able to integrate the changes, even if it means have my own settings evolved accordingly (i.e. merge in a way).
By the way, I work on linux, so probably there is also a solution with symbolic links and submodules?
Any good idea?
Cheers
|
I would use a branch for this:
Clone the external repository locally.
Create a branch based off whichever remote branch is appropriate (I’ll assume that’s origin/main).
Make your changes and commit them to your branch.
Whenever you want to update your branch with changes made to the external repository:
git fetch
git rebase origin/main
If there are any conflicts you’ll have to resolve them.
If you want to back your changes up somewhere, you might as well fork the original repository, there’s no meaning associated with that and it’s fine to fork repositories when you don’t intend to contribute back.
| Track my slight changes to an external git repository I cannot push |
1,372,926,892,000 |
I am using git on Ubunto with bash shell, and a tab-completion using bind '"\t":menu-complete' in my .bashrc file. When I do git diff X, tab-completion starts cycling with matching git tags, instead of matching files. If I complete enough characters such that no tags match, only then does the file-name completion works. How can I make git match both tags and files? Or, disable tag-matching temporarilty?
|
If you type
git diff --
before starting to enter file names, tab-completion should only consider files.
| git diff tab completion of tags hides file name completion (using bash) |
1,372,926,892,000 |
I have configured git diff to be a command that calls substitute diff for viewing file differences i.e /usr/bin/vim -dR "$2" "$3" and that doesn't work when I want to create a patch using git diff > patchfile.
Is there a way to invoke directly git's own built in diff without disabling the subsitute diff I use for visual compares?
|
git diff --no-ext-diff
In general look for a --no-thing option for turning whatever --thing off. git(1) has a lot of those. Good for conveniently turning off defaults. Sometimes they’re documented together as --[no-]thing and sometimes separately in the man pages.
| How can I call git's built-in diff command directly after configuring a different visual "git diff" substitute? |
1,372,926,892,000 |
Referring to this https://stackoverflow.com/a/31356602, I wrote this code:
#!/bin/bash
# Define the two strings to compare
string1="First string with some random text."
string2="Second string with some random text and some changes."
# Create a temporary directory
temp_dir=$(mktemp -d)
# Create temporary files for the strings
file1="$temp_dir/string1.txt"
file2="$temp_dir/string2.txt"
echo -e "$string1" > "$file1"
echo -e "$string2" > "$file2"
# Use the git diff command to compare the temporary files
git diff --no-index --word-diff=color --word-diff-regex=. "$file1" "$file2"
# Delete the temporary directory
rm -rf "$temp_dir"
that returns:
Now I'm trying to condensate it in a single line:
#!/bin/bash
# Define the two strings to compare
string1="First string with some random text."
string2="Second string with some random text and some changes."
# Use the git diff command to compare the strings
git diff --no-index --word-diff=color --word-diff-regex=. <('%s\n' "$string1") <(printf '%s\n' "$string2")
but I get:
How can I pass strings as files to git diff without explicitly creating temporary files?
Note. My goal is to "visually" compare (character-level) two (short) strings, obtaining an output similar to this:
in which the differences between the two compared strings are highlighted in a single string. The output of git diff is ideal, but I am also open to other solutions.
|
This won't be possible with pipe-based redirection as in your bash's <().
But: with zsh-isms, it should work. There is the temporary file expansion =():
#!/usr/bin/zsh
# use zsh instead of bash
# Define the two strings to compare
string1="First string with some random text."
string2="Second string with some random text and some changes."
# Use the git diff command to compare the strings
git diff \
--no-index \
--word-diff=color --word-diff-regex=. \
=(printf '%s\n' "$string1") \
=(printf '%s\n' "$string2")
| Performing character-level comparison of "strings" without explicitly creating temporary files for git diff |
1,372,926,892,000 |
My .gitignore file is instructing to ignore the ../../.aws/ directory:
$ cat .gitignore
coredumps/
../../.aws/
.*.sw*
*bak
*log
Alas, that instruction is ignored:
$ git status | head -6
# On branch main
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# ../../.aws/
# ../../.bash_history
How should I change my .gitignore so that the ../../.aws/ will be excluded from the git status output?
|
The .gitignore file applies to the files in the same directory where it is located and its subdirectories. It doesn't apply to parent directories or their other subdirectories. You're trying to ignore ../../.aws/, which is two directories above where your .gitignore file is located.
Here are a few ways to handle this:
Place a .gitignore file in the appropriate directory: If you have the ability to place a .gitignore file in the .aws/ directory or its immediate parent directory, you could do that. In that .gitignore file, you would add an entry to ignore the .aws/ directory.
Use a global .gitignore file: If you want to ignore files like this across all of your Git repositories, you can create a global .gitignore file:
git config --global core.excludesfile '~/.gitignore_global'
Then you can add .aws/ to this ~/.gitignore_global file.
Remember, if files in .aws/ directory were previously tracked by Git, you need to remove them from the repository before Git starts ignoring them. You can do this without deleting the local copies of the files with the command:
git rm --cached -r .aws/
After running this command, Git will stop tracking the changes in the .aws/ directory.
| How to set `.gitignore` so that `../../.aws/` is excluded from `git status` output? |
1,372,926,892,000 | ERROR: type should be string, got "\nhttps://wiki.postgresql.org/wiki/Working_with_Git#Using_git_hooks\nI want to quickly test my idea (fail fast).\nSo whatever I changed, committed to the local branch. then I switch to a new branch using\ngit checkout -b test1\n\nI can quickly get local as latest as remote (master branch) then I do new changes.\nHow to automate this using git hooks.\n\nhttps://postgresql.life/post/andrey_borodin/\n\nI think what I do is an antipattern. I have at $HOME directories\npostgres0, postgres1, postgres2…postgresE, postgresF, postgres10…\nWhenever I do not understand what I was changing in postgresX - I do\ngit clone https://github.com/postgres/postgres postgresX+1.\nYes, I know git was invented for a reason. But to give a name to the\nbranch I need at least a subtle understanding of what was the purpose\nof changes.\n\nBasically, when I create a new branch, I can get the latest remote automatically.\nBut before I switch if the old branch doesn't commit, the old branch will be lost? (so I need to prevent this).\n\nI want to make sure every time I use \"git checkout -b\", the new branch's local content is as fresh as the latest remote. (That means later when I make some change or break something, it's all my fault) also, the previous branch's changes are still there. (I want to automate this).\n" |
Following a discussion in chat we clarified what the OP wanted.
Suppose the upstream had commits R1, R2, and R3 on it.
The local branch1 had these (R1, R2, R3) and some local commits L1 and L2.
Another commit is made to the remote (R4).
Then a new branch is created locally (branch2) and selected. The question is how to use git hooks so that branch2 is up to date with respect to the remote, in effect to do a git fetch automatically.
This is not something that is suitable for git hooks. One can argue that it is not suitable for git aliases either, as it is not known if the remote is accessible at the time the branch is being created.
Anyway the desired sequence of commands is (assuming the remote is called the traditional origin
# get the changes from origin/master
git fetch origin
# If you want a linear history, with the local changes, create the
# new branch
git switch -c branch2
git rebase origin/master
If there are edit conflicts between L1+L2 and R4 they will be reported in the rebase and need to be fixed.
This will leave branch1 as R1-R2-R3-L1-L2 and branch2 as R1-R2-R3-R4-L1'-L2'.
| Automate when create new git branch |
1,372,926,892,000 |
I'm using git diff to return the file names of files recently changed and i'm trying to pipe the returned file names into a grep expression that searches each file and returns the files that have "*.yml" in the file name and "- name:" in the actual file. However it seems like my code only returns all the files in the directory that match the conditions, basically ignoring the git diff.
files=($(git -C ${dir} diff --name-only HEAD^ HEAD | grep -rlw --include="*.yml" --exclude-dir=$excluded_paths-e "- name:"))
Any help would appreciated!
|
git diff --name-only produces a list of files; you need to give that list to grep in a form it will understand, i.e. as command-line arguments. One way to do this is
git -C "${dir}" diff -z --name-only HEAD^ HEAD | xargs -0 grep -lw --include="*.yml" --exclude-dir="$excluded_paths" -e "- name:"
I added -z so that the file names are separated by null bytes; the -0 xargs option specifies the same delimiter for use in xargs’ input. I removed the -r option from grep — that is used for recursive searches, which is counter-productive here since the exact list of files to check is given.
| Return list using git diff and grep |
1,372,926,892,000 |
I have a bash script in a git repo. I used git pull inside the script to update. But sometimes, when I do changes to the script itself, the whole script crashes because it is changed during execution. I want something to update this file but not during the execution.
How could I do this??
|
Universal way
One of the common way to solve such problem is to have two versions of the script - one to run, another to store in repository. It works for any version control system, and even if the script is downloaded from the web.
For example, you can have update.sh.in (add it to repository):
#!/bin/bash
git pull
if [ update.sh.in -nt update.sh ]; then cp update.sh.in update.sh; fi
# actual work of the script
# any line here can be changed in the next version of the script
Manually copy that file into update.sh, include it into .gitignore. Run the update.sh.
The trick here is that the first three lines should not be modified. As long as the copy of .sh.in into .sh remain in the same position of the script - it can be run without a problem.
The .in extension is a traditional extension for various tools which generate actual script or source code from template files.
GIT hooks
Another, also common, but maybe less so, way: is to use git hooks. That is a GIT-specific approach. You can write additional scripts and put them inside .git/hooks directory. Git will call these scripts in various points of execution.
You did not specify what exactly do you need to do beside git pull. But probably, you can put your special work into .git/hooks/pre-rebase or .git/hook/post-merge. which are called automatically for git pull.
For full list of hooks read here: https://git-scm.com/docs/githooks
| update during execution |
1,372,926,892,000 |
I wish to create a pull request describing the incoming commits. Is it possible only through the interface or must I do some coding?
My thoughts:
Duplicate pull request template with appended _orig tag;
Parse git log
Add some placeholders manually or programmatically on the pull request copy
Add parsed comments on the template without _orig tag;
Commit changes and push.
What do you think?
|
This is technically possible, but unpractical in real life.
What if your pull-push cicle contains a few dozens of commits? Once you start implementing a new feature or upgrade versions - the number of commits can easily be in the hundreds (often with comments like: "adding X", "Removing X - bad idea", "Adding X back", "Removing X - still bad idea"). How do you expect to automate that?
The interface approach is much easier and more reliable. You can of course, reread log of commits to remind yourself what list of features/bugs were solved in them, but the final message for merge commit should come from a keyboard.
| Add incoming commits to pull request description |
1,372,926,892,000 |
With this .gitignore I expect that *.log files under directory test will not be included in any git transactions
:> cat ~/test/.gitignore
*/*/*.log
*/*/*__pycache__*
*/*/*out
However I have this conversation which suggests my gitignore is not defined to do what I expect.
Where is my error? Am I misinterpreting the conversation or is my .gitignore incorrect for what I expect.
:> git add .
===
:> git status
On branch master
Your branch is up to date with 'origin/master'.
===
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
new file: ftp.log
===
:> git restore --staged ftp.log
===
:> git status
Untracked files:
(use "git add <file>..." to include in what will be committed)
ftp.log
nothing added to commit but untracked files present (use "git add" to track)
|
If you just want to exclude the directory test you can add a new .gitignore to the test directory with the following:
*.log
You can also replace what you have in your current .gitignore:
*/*/*.log
with
**/*.log
to remove tracking from all .log files in directories of the project.
| trouble with gitignore |
1,372,926,892,000 |
Perhaps a dumb question, but I am new at this - so please bear with me.
Here is a brief description of the situation:
I recently learned of a significant, long-standing bug in dhcpcd - the default network manager for RPi OS. Coincidentally, someone submitted a pull request to the dhcpcd GitHub site that was committed recently.
The RPi organization does not publish their dhcpcd sources on GitHub, but they are available via apt-get source dhcpcd5. This yielded a new folder (~/dhcpcd5-8.1.2), a .dsc file (with several inaccuracies), and a compressed tar file (dhcpcd5_8.1.2.orig.tar.xz) - there was no diff.gz file/folder. I have incorporated the simple source code correction (one single line of code), and learned enough to successfully build a new .deb file. I have installed and tested the .deb file on 3 of my systems; it resolves the issue & I've found no side-effects
I've advised an individual in the RPi organization of my findings some time ago, but have gotten no feedback. Apparently there is no venue for submitting user-proposed changes to the Debian package source files - no pull request mechanism iow.
I'd like to share my effort. It has occurred to me that there may (should?) be a method whereby I can effectively create a git repo from the contents of the Debian package dhcpcd source files. I know enough git to upload the contents of ~/dhcpcd5-8.1.2 into a GitHub repo; but my questions are these:
The folder ~/dhcpcd5-8.1.2 contains some binary files. I think those files were created during the debuild process. How do I purge binaries from the sources in ~/dhcpcd5-8.1.2?
There are several patches in dhcpcd5-8.1.2/debian/patches; can I safely rely on these answers from 2016 to ensure all the patches are applied to the source code?
As I don't know enough to ask any further questions, I'll ask instead: "Will this work?" Meaning that if all the binaries are removed, and the current change & all previous patches are applied -- will someone with no specific expertise be able to clone the GitHub repo I want to create, and build it using debuild -b -uc -us?
|
To clean a Debian package, i.e. remove all generated files and restore the source to its initial state, run
fakeroot debian/rules clean
dhcpcd5 is a “3.0 (quilt)”-format package, so extracting it with apt source etc. will extract it and apply any patches. You can further make sure of this by running
quilt push -a
If what you have locally builds with debuild, then yes, pushing your repository as-is will produce something that others can build, as long as they can also retrieve the corresponding .orig tarball. Note that your repository should contain the sources with patches unapplied, i.e. you should run
quilt pop -a
before committing your changes and pushing the repository.
There is a Debian git repository for dhcpcd5, but it hasn’t been maintained for a long time and is probably irrelevant here.
| Conversion of Debian "source package" for use on GitHub |
1,372,926,892,000 |
The code below is adapted from a solution to "Use Expect in a Bash script to provide a password to an SSH command", so as to pass arguments to git push. I'm not getting any exceptions for passing the wrong uname+pwd, and conversely passing the correct ones does not actually push anything. How can this be corrected?
git_push.sh
if (( $# == 2 ))
then
:
else
echo "expecting 'username pass', got $@"
exit 1
fi
user="$1"
pass="$2"
expect - <<EOF
spawn git push
expect 'User*'
send "$user\r"
expect 'Pass*'
send "$pass\r"
EOF
Terminal:
$ [path]/git_push.sh
spawn git push
Username for 'https://github.com': foo
Password for 'https://[email protected]':
Alternatively (no wildcards):
spawn git push
expect "Username for 'https://github.com': "
send "$user\r"
expect "Password for 'https://[email protected]': "
send "$pass\r"
|
To address the expect questions:
expect - <<EOF
spawn git push
expect 'User*'
send "$user\r"
expect 'Pass*'
send "$pass\r"
EOF
single quotes have no special meaning in expect, so you are looking for literal single quotes in the User and Pass prompts. Those prompt will not contain single quotes, so the expect command hangs until the timeout (default 10 seconds) happens.
after you send the password, you don't wait for the push to complete: the expect script runs out of commands to run and exits too early, killing the git process. After any send, you should expect something. In this case, you're expecting the spawned command to end which is denoted with expect eof
expect - <<_END_EXPECT
spawn git push
expect "User*"
send "$user\r"
expect "Pass*"
send "$pass\r"
set timeout -1 ; # no timeout
expect eof
_END_EXPECT
| How to correctly use spawn-expect-send for 'git push'? |
1,372,926,892,000 |
To apply some changes to all my pom.xml files, I'm running these commands:
git checkout --theirs **/**/**/**/pom.xml
git checkout --theirs **/**/**/pom.xml
git checkout --theirs **/**/pom.xml
git checkout --theirs **/pom.xml
git checkout --theirs pom.xml
But I can't find the replacement that would target all the pom.xml files, at any level of directories depth they would be.
How can do what I did in a single command?
|
There are two possible answers here depending on your requirement. You can't use a shell wildcard to match a file or directory that doesn't yet exist, so you cannot use shell wildcards to instruct git on which items to check out unless they are already present in your filesystem. Fortunately git itself does support wildcards for exactly this situation.
Specifically for git, you need to pass the ** to git itself without the shell trying to expand it. In this situation use quotes to pass the string as a literal to git:
git checkout '**/pom.xml'
Outside of git the bash shell also supports double-star wildcard expansion. The documentation (man bash) writes,
globstar If set, the pattern ** used in a pathname expansion context will match all files and zero or more directories and subdirectories. If the pattern is followed by a /, only directories and subdirectories match.
It's an option in bash that's usually not enabled by default so you would need to enable it:
shopt -s globstar
Example thereafter,
ls **/pom.xml
| pom.xml, **/pom.xml, **/**/pom.xml, then **/**/**/pom.xml... What shortcut to target a file we know its name, whatever its depth in directories? |
1,372,926,892,000 |
In my .zshrc, I am using following git command (from zsh prompt: check whether inside git repository and not being ignored by git) to check whether I am inside a git repository, so that I can change the prompt accordingly:
git check-ignore -q . 2>/dev/null
if [[ $? -eq 1 ]] ; then
But this command does not distinguish whether I own this repository or not.
This could be owned by other user on the system, and I don't have write permissions.
Is it possible to check whether I own the .git directory or whether I have write permissions?
|
Presumably you care about write permissions on the .git directory itself; if so,
git check-ignore -q . 2>/dev/null
if [[ $? -eq 1 && -w "$(git rev-parse --show-toplevel)/.git" ]]; then
will run the then block only if the current directory is a non-ignored directory in a git repository, and the relevant .git directory is writable for the current user.
You can use git rev-parse as a test for being inside a git repository too; so if you don’t care about ignored directories inside git repositories,
if top="$(git rev-parse --show-toplevel 2>/dev/null)" && [ -w "$top/.git" ]; then
will determine whether the current workspace’s .git directory, if any, is writable.
See also [ -O "$top/.git" ] to check whether you own that directory (not standard but supported by most tests / shells including zsh)
| zsh: check whether I am currently inside my git repository (git check-ignore) |
1,372,926,892,000 |
I have on system A a (remote, read-only mounted from server B via sftp/sshfs) filesystem with data on it that needs to be pushed to a remote git repository regularly.
I was not able to find a git command that just takes the contents of a directory (and its subdirectories) and pushes it to a remote repository, without turning the local directory into a repository itself (which would require writing into the locally mounted read-only directory).
One could maybe put an overlayfs on top of the remote directory's mountpoint on server A but I read that changes on lowerdir (which will happen on server B) could occasionaly cause issues with stale file handles which in turn can sometimes only be fixed by rebooting the machine (A).
Due to the large amount of data that needs to be pushed, temporarily copying it to the local machine A and git-pushing from there is not an option.
EDIT: The files are hosted on server B in a restricted network with no access to the git repository.
|
Git cannot push the contents of a directory to a remote server without having some sort of repository to store the data in. However, if you want to store the Git directory on a different disk or partition, you can do so.
To do that, you can set the environment variable GIT_DIR to point to the directory you'd like to use instead of .git and GIT_WORK_TREE to point to directory you'd like to use as your working tree (which would be the directory with the data you want to commit). You can then run Git commands as normal, including git init to initialize the repository, git add and git commit, and so on.
However, this will result in objects being written to the local system, which will take some disk space, even though they'll be compressed. That will probably be substantially less than the working tree, though. If that amount of disk space is too much, then unfortunately there's no way to do what you want to do, and you'll have to adopt a different approach.
| Push contents of a read-only file system to remote git repo |
1,372,926,892,000 |
I Stowed a couple of files which were in a folder. This folder is a config folder and has other temp or system specific files which I don't want in my Git backed Stow backup.
What is the best way to only commit intentional files in Stow's git repository? Is it more or less not using git commit -a?
Regards
|
Add a line with just * to the .gitignore file. git add will then only add files or directories when you force it to with the -f option.
For example:
$ mkdir /tmp/git-test
$ cd /tmp/git-test
$ git init
hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint:
hint: git config --global init.defaultBranch <name>
hint:
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint:
hint: git branch -m <name>
Initialized empty Git repository in /tmp/git-test/.git/
$ date > file1.txt
$ date > file2.txt
$ date > file3.txt
$ git status
On branch master
No commits yet
Untracked files:
(use "git add <file>..." to include in what will be committed)
file1.txt
file2.txt
file3.txt
nothing added to commit but untracked files present (use "git add" to track)
$ echo '*' > .gitignore
$ git status
On branch master
No commits yet
nothing to commit (create/copy files and use "git add" to track)
$ git add file1.txt
The following paths are ignored by one of your .gitignore files:
file1.txt
hint: Use -f if you really want to add them.
hint: Turn this message off by running
hint: "git config advice.addIgnoredFile false"
$ git add -f file1.txt
$ git status
On branch master
No commits yet
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: file1.txt
$ git commit -m 'initial commit'
[master (root-commit) 2007ca3] initial commit
1 file changed, 1 insertion(+)
create mode 100644 file1.txt
$ date >> file1.txt
$ git status
On branch master
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: file1.txt
no changes added to commit (use "git add" and/or "git commit -a")
$ git commit -m '2nd commit' .
[master dba5fea] 2nd commit
1 file changed, 1 insertion(+)
$ git commit -m '3rd commit' *
error: pathspec 'file2.txt' did not match any file(s) known to git
error: pathspec 'file3.txt' did not match any file(s) known to git
$ date >> file1.txt
$ git commit -a -m '3rd commit'
[master e679fde] 3rd commit
1 file changed, 1 insertion(+)
$ mkdir foo
$ date >> foo/bar.txt
$ git status
On branch master
nothing to commit, working tree clean
$ git add -f foo
$ git status
On branch master
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
new file: foo/bar.txt
$ git commit -a -m '4th commit'
[master 4048a90] 4th commit
1 file changed, 1 insertion(+)
create mode 100644 foo/bar.txt
| Non-stowed files in stow directory and git |
1,372,926,892,000 |
For example, in this page :
https://elixir.bootlin.com/linux/latest/source/arch/arm64/boot/dts/arm/fvp-base-revc.dts
I want to download the .dts file. But if I just do
wget https://elixir.bootlin.com/linux/latest/source/arch/arm64/boot/dts/arm/fvp-base-revc.dts
it's not .dts file but a html-like file.
How can I download the displayed source?
|
As far as I’m aware, Elixir doesn’t provide a way to download the raw file it presents through its web interface. Instead, you should download the file you’re interested in from a git repository, e.g.
wget https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/plain/arch/arm64/boot/dts/arm/fvp-base-revc.dts
I.e. replace https://elixir.bootlin.com/linux/latest/source/ with https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/plain/ (both of these track the tip of Linus Torvalds’ tree).
| how to get raw file from a web page showing source file? |
1,372,926,892,000 |
Goal
Clone repos into subdirectories named .owner.login (argument in Github's REST API) with jq, git clone, and xargs.
Preface
I took a code somewhere that allowed me to clone repos with jq, git clone, and xargs. However, I was not able to set it up so that it would make a new parent directory for each repos. (I am a Windows user but for what I am trying to achieve I was not able to query any other solution but this bash script. I do not have any knowledge of how GNU commands interact together and this is the most I can put together)
Original code
UserName=CHANGEME; \
curl -s "https://api.github.com/users/$UserName/repos?per_page=1000" |\
jq -r '.[].html_url' |\
xargs -l git clone
This is my modification:
UserName=CHANGEME; \
curl -s "https://api.github.com/users/$UserName/repos?per_page=1000" |\
jq -r '.[] | .html_url, .full_name' |\
xargs -l git clone
I got the same result as the original code. And this error log:
fatal: repository 'repoauthor/reponame?' does not exist
I don't know where the \? came from.
So I tried to debug it
by splitting the code into
UserName=CHANGEME; \
curl -s "https://api.github.com/users/$UserName/repos?per_page=1000" |\
jq -r '.[] | .html_url, .full_name'
which returned this:
https://github.com/repo1name/repo1author
repo1name/repo1author
https://github.com/repo2name/repo2author
repo2name/repo2author
... etc
It returned .html_url, .full_name in 2 different lines instead of a single line.
I thought that it was the issue but then I tried to run xargs separately:
https://github.com/repoauthor/reponame |\
xargs -l git clone
It just make me go into the git help file.
tl;dr
I need to integrate the strings generated by jq into xargs. However, jq generated the important string into two different lines, and MAYBE that's what's causing the bug but I don't know how to resolve it.
|
As you don't give us a specific Github user for reproducing your specific issue, I have tested with other Github accounts that I know of myself.
There are two main issues with your attempts.
The individual arguments read by xargs should ideally be quoted.
xargs needs to call git clone with two separate arguments: the repository URL and the destination directory into which to clone it.
You may sort out the quoting of the arguments like this:
curl -s "https://api.github.com/users/$UserName/repos?per_page=1000" |
jq -r '.[] | [ .html_url, .full_name ] | @sh'
This extracts the wanted info from the response to the curl request into an array, and then uses the @sh operator to output a each such array as a line of shell-quoted words.
Strictly speaking, we could have used just .[] | .html_url, .full_name | @sh as the jq expression to get a stream of lines with single shell-quoted strings on them too, it doesn't matter for xargs the way we're going to use it.
Given this stream of words, we then call git clone via xargs:
xargs -n 2 git clone
The -n 2 means xargs will call the utility with two arguments from its input stream at a time.
Putting it together:
curl -s "https://api.github.com/users/$UserName/repos?per_page=1000" |
jq -r '.[] | [ .html_url, .full_name ] | @sh' |
xargs -n 2 git clone
| git clone repos with xargs and jq to a subfolder with the name of .owner.login (part of .full_name) |
1,372,926,892,000 |
In ubuntu Linux, I have a bunch of abominably broken symlinks like:
$ ls -l setup.conf
lrwxrwxrwx 1 ont ont 27 Aug 19 15:26 setup.conf -> '# Source it'$'\r''. ../setup.conf'
They are the result of an attempt to replace all symlinks in a project with a comment and a source call (". ../setup.conf") of the target file. They are all really text files (the example containing: "# Source it\n. .../setup.conf") with the symlink bit. This was done using git and windows.
One theoretical fix would be to just remove the "symlink bit" and keep the resulting textfile as is, but I see no way of doing that (chmod and other tools sees it as a "dangling symlink" and refuses to operate on the text-file itself).
Another fix would be to manually create a new file, with contents as the above as taken from the ls command. I'd rather not resort to that, as it is tedious and error prone, and the files are not identical).
EDIT: ADDED:
I want to end up with a regular file named setup.conf whose contents are
"# Source it<newline>. ../setup.conf'"
|
I'm not entirely sure whether you want to fix the symlinks or replace them with text files. This solution replaces the symlinks with text files:
find -type l -exec bash -c '
for f in "$@"
do
t=$(readlink "$f")
rm -f "$f"
printf "%s\n" "$t" >"$f"
done
' _ {} +
You can test non-destructively by removing the rm and amending the printf to write to "$f.tmp.txt" instead of "$f". (Just remember to remove the .tmp.txt text files afterwards.)
If you want the \r replaced with \n for easier readability you can do that too:
printf "%s\n" "${t//'$'\r/\n''}" >"$f" # non-POSIX
printf "%s\n" "$t" | tr "\r" "\n" >"$f" # POSIX
| How to change a symlink (viewed as a text file) to the content of that text file (i.e. "remove symlink bit")? |
1,372,926,892,000 |
Is it possible to bulk/sequentially download all of the *.tar.gz from a GitHub repo? Instead of manually downloading everything, is it possible to do so using a certain command or would I have to create a script? I'm using Linux.
|
You should first consider simply cloning the repository with git, it's then easier to do comparisons between releases. That's out of the scope of this Q/A.
I present two methods: a web-based approach, and a GitHub specific approach using an API:
Web scraping
Here's a quick-n-dirty one-liner script (split here into multiple lines for some readability), requiring w3m, awk, xargs and curl. This ad hoc script is probably not meant to be used within anything automated.
using w3m to format the page contents with all links at the end,
awk to extract only the links including the string /releases/download/ and ending with .tar.gz in their URL,
xargs to convert output into command line parameters to feed to
curl to download them. It's even suitable for n parallel downloads by adding -P n to xargs:
.
w3m -o display_link_number=1 -dump https://github.com/GloriousEggroll/proton-ge-custom/releases |
awk '$1 ~ /\[[0-9]+\]/ && $2 ~ /\/releases\/download\/.*\.tar\.gz$/ { print $2 }' |
xargs -n 1 curl -JRLO
inserting echo before curl to prevent the download to actually happen outputs this:
curl -JRLO https://github.com/GloriousEggroll/proton-ge-custom/releases/download/6.10-GE-1/Proton-6.10-GE-1.tar.gz
curl -JRLO https://github.com/GloriousEggroll/proton-ge-custom/releases/download/6.9-GE-2-github-actions-test/Proton-6.9-GE-2-github-actions-test.tar.gz
curl -JRLO https://github.com/GloriousEggroll/proton-ge-custom/releases/download/6.9-GE-2/Proton-6.9-GE-2.tar.gz
curl -JRLO https://github.com/GloriousEggroll/proton-ge-custom/releases/download/6.9-GE-1/Proton-6.9-GE-1.tar.gz
curl -JRLO https://github.com/GloriousEggroll/proton-ge-custom/releases/download/6.8-GE-2/Proton-6.8-GE-2.tar.gz
curl -JRLO https://github.com/GloriousEggroll/proton-ge-custom/releases/download/6.8-GE-1/Proton-6.8-GE-1.tar.gz
note: the -o display_link_number=1 option isn't really documented but appears as example in w3m's man page.
This will be limited to the contents of the first page, so won't make all downloads available. As the next page link requires to know the contents (specifically the last displayed release in the page), handling this would get too complex.
Better use the...
GitHub REST API
There's a GitHub API related to releases that doesn't appear to require any credential for this task and outputs its results in JSON format, suitable for script processing with jq (it's usually available as distribution package). This requires curl, xargs, jq. jq will display the download URL for every assets' name ending in .tar.gz. (Examining first the initial curl dump with | jq . allows to find the useful parts).
curl -H 'Accept: application/vnd.github.v3+json' 'https://api.github.com/repos/GloriousEggroll/proton-ge-custom/releases' |
jq -r '
.[].assets[] | if .name | endswith(".tar.gz") then
.browser_download_url
else
empty
end' |
xargs -n 1 curl -JRLO
Inserting echo before the last curl will give the same output as in the first method, except there will be 30 of them instead of ~ 6.
As described in the API, per_page defaults to 30. Adding to the URL ?per_page=XX can go up to 100 results. Anything bigger would need a loop with also the additional parameter &page=Y and detecting when it ends.
| Bulk download of certain files from a GitHub repo |
1,372,926,892,000 |
I am starting with bash and I had this expression line. I am lost figuring what it is means.
what does this line in shell regex expression mean?
find . -name '*.sh' | sed 's#.*/##' | sed 's#\.sh##'
|
The find statement searches the current directory and its sub-directories for all files ending in .sh and prints them one file per line.
The s operator of sed substitutes matched substrings with something else.
The syntax is s<delimiter>regex<delimiter>replacement<delimiter>.
Usually / is used as the delimiter but here # is used.
The replacement in both sed statements is the empty string.
Therefore the first statement cuts off everything before the last / in the filename (ie. the sub-directory).
The second statement cuts off the .sh suffix of the file name.
A file a/subdir/hierarchy/my_script.sh would be printed as my_script.
| regex expression shell help finding the meaning |
1,372,926,892,000 |
Is there a way to fetch the remote repository of a non-checked-out remote repository with git?
I have the dotfiles on my remote PC under version control (using yadm). This repository is cloned on my local PC (also using yadm). But on my local PC I'm using a different dotfiles management utility (rcm) which allows for more flexibility.
Since yadm and rcm work on a different basis (symlinks to ~ vs. bare git into ~) I have to jump through hoops to try stuff using yadm on my local PC:
unlink my current symlink-dotfiles with rcm
checkout the yadm-repository
To undo that I then have to
remove all the files which were cloned when checking out the yadm-repository
symlink the files with rcm
This is annoying. Therefore I cloned the local clone of my yadm-repository into a different folder. While I'm able to see all the remotes in my local main yadm-repository, I'm only able to fetch HEAD in the cloned yadm-repository.
It looks like that:
remote PC (1): commit a (old, not checked out), commit b (HEAD -> master)
local PC - main repository (2): commit a (HEAD -> master), commit b (origin/master, not checked out)
local PC - other repository (3): commit a (HEAD -> master), commit a origin/master
So on my repository 3 I'm only able to see the commit a (which is checked out in repository 2), but not commit b (which is not checked out in repository 2, but should be available there). My question is now: how can I get commit b in my repository 3 and why doesn't that work by just git fetching everything?
Update 1: Minor edits to the text were performed to (hopefully) make the issue clearer.
|
Since each of the repositories are not bare repositories, at least where it matters, they are not. Therefore, the default behavior seems to be what has been observed, i.e., repository 3 only sees the checked-out commit of repository 2.
To override this behavior, git fetch has an optional refspec argument which can be used to specifically fetch the other revision. Mapping this to a different branch will likely make this a bit easier.
git fetch origin b
Or since origin/master points to commit b, using origin/master as the refspec should also work:
git fetch origin origin/master
Again, having commit b on a branch or tag would likely make this fetch easier. If that is not the case, it's necessary to perform the merge by manually specifying the hash of the commit (although it will not be visible using git log --all).
| how to fetch the remote repository of a remote repository which is not checked out in git |
1,372,926,892,000 |
I have a laptop, where repository A, which reside in the home directory, under an example name test.
I have commited a couple of things, namely text file, etc into that same repository.
The usb stick, which is plugged in the laptop, is automatically mounted using a cronjob.
What are the ways to sync the repository between those two local endpoint (they do not face internet)?
|
Inside repository A, add the repository on the USB stick as a remote:
git remote add usbstick /mnt/...
Then you’ll be able to push your changes:
git push usbstick master
(if your branch name is master).
If you make changes to the USB stick elsewhere, you can pull them using git pull. If you make changes in both repositories, you’ll need to merge them, or rebase one on top of the other.
| Git - Sync local repository between a usb stick and a computer |
1,372,926,892,000 |
I'm trying to install Picom compositor on Ubuntu and have installed all the dependencies but when I get to the "To Build" section of the guide of GitHub I have to run three commands:
$ git submodule update --init --recursive
$ meson --buildtype=release . build
$ ninja -C build
None of which seem to work. Running the first returns...
fatal: not a git repository (or any of the parent directories): .git
So I tried making my own picom folder, running git init. This gets me to command number two which fails, responding with:
ERROR: Neither directory contains a build file meson.build.
I feel like I'm giving the order to build with bricks that I have yet to download. I would appreciate if someone could point to where I have gone wrong or how I might better troubleshoot my problem.
|
You first have to clone the repository i.e bring the code at the github to your computer and you can continue. So run these commands.
$ git clone https://github.com/yshui/picom.git
$ cd picom
$ git submodule update --init --recursive
$ meson --buildtype=release . build
$ ninja -C build
| `not a git repository` when following install instructions for picom (a compton fork) |
1,372,926,892,000 |
I have two servers which I'm running the command git fsck on specific bitbucket repository.
in both servers, I'm getting this output:
Checking object directories: 100% (256/256), done.
error: object directory /XXX/XXX/XXX/XXXX/XXX/objects does not exist; check .git/objects/info/alternates.
error: HEAD: invalid sha1 pointer fda39345603cdbab032ac57635405fc90d827f3c
error: refs/heads/master does not point to a valid object!
notice: No default references
however, when running echo $?, one of them returns 0 and the other returns 2. how is it possible?
|
As suggested by @vonbrand in a comment, it was a git version issue. once I upgrade it, it was aligned.
another issue was the structure, I had to create a similar structure with soft link to get rid of those errors.
| different behavior for git fsck |
1,372,926,892,000 |
Using git, I often create local branches and then want to push them to the remote (e.g. Github). This requires the -u or --set-upstream flag.
Here is what git outputs without this flag:
$ git checkout -b newbranch
$ git push
fatal: The current branch cross_val has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin newbranch
Is there a way to have this suggestion copied to my prompt? So that I don't have to type it. Something like:
$ git checkout -b newbranch
$ git push
fatal: The current branch cross_val has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin newbranch
$ <tab>
$ git push --set-upstream origin newbranch
|
You could set up an alias that pushes the current branch to the remote.
Configure the alias with the following command:
git config --global alias.rpush '!git push --set-upstream origin $(git rev-parse --abbrev-ref HEAD)'
The git rev-parse --abbrev-ref HEAD command returns the name of your current branch. Then run it with:
git rpush
You can choose to give the alias any other name according to your own preference.
| Git: autocomplete my prompt after failed push because missing -u flag |
1,372,926,892,000 |
I'm reviewing a repo and I'd like to make some comments, it would add more content like adding comments, make some changes ..etc.
How to change content of files of previous commit and do push, I'm aware that commit history would be changed and all affected files would be changed also, but would git compare the affected files with further commits (--> Master) and do change aggressively?
|
What you are asking for is to rewrite history n to 0 commits back. This is generally a bad idea as it would make you repo out of sync from the remote and any other repo that is based on it. This would further complicate things so that others wouldn't be able to merge anymore and would require any other repo to delete their branch and pull down the newly modified one. In which case, you might as well just start a new branch and add the comments to that. In any case, this'll get a little messy.
To do this, you have your merges that you would be reviewing (as an example, we'll use commits A, B and C) and then go back to A, branch off that (we'll call that branch review, and the original pull-request):
...A --B --C (pull-request)
\
A' (review)
git checkout HEAD{3}
git checkout -b review
Then do your comment modifications and check them in.
git add . # or specify the specific files
git commit -m "message" --author="original author"
Or if you want the same message/author and don't want to type it out, you can use the following, which I would either put into a script or an alias git command:
git add $(git diff-tree --no-commit-id --name-only -r <sha-of-A>)
git commit -m "$(git rev-list --format=%B <sha-of-a>)" --author="$(git rev-list --format=%an <sha-of-A>)"
Could also be done automatically by retrieving the appropriate sha from the appropriate parent, but I'm not exactly sure how to distinguish between the branch parent and the merge parent atm.
Next merge B into review
git merge <sha-of-B>
Then do your comment modifications and check them in. (see above).
Keep doing this till you're done and you have:
...A --B --C (pull-request)
\ \ \
A'--B'--C' (review)
You can then merge back into your original branch if you wish or just give that review branch back to the person from which you are reviewing.
| Git: change content of previous commit and push [closed] |
1,372,926,892,000 |
I tried links in this article, seem doesn't work for me: https://stackoverflow.com/questions/31801271/what-are-the-supported-git-url-formats
Problem that I have setup a local git server at /srv/repo/ for example, and when I create a repo under it name test.git with --bare under username testuser, I'd like to add this test.git as remote from other local machine in the same network.
For example, local git server has ip address at 192.168.1.10, and I need to add its repo on machine that has ip address of 192.168.1.100 for example.
If I use this URL and change user owner of test.git, I can do a push and pull, meaning it works as expected:
sudo chown -R git:testuser test.git/
sudo chown -R git:testuser test.git/*
[email protected]:/srv/repo/test.git
But I created repo using another user called testuser, probably user and group owner of repo test.git belong to testuser, and push and pull will fail if I do NOT change the user owner of test.git to git: sudo chown -R git:testuser test.git/*
I'd like to add remote repo as: git://192.168.1.10/~testuser/srv/repo/test.git/ that use testuser as user instead of git user because I create test.git under testuser.
|
If you are using the SSH protocol to access the server-side repository, your read/write permissions are determined by the user/group/world permissions on the server. To set this permission on the repository, you can use the git init command with the --shared parameter when you create your repository. Setting --shared=true will set the repository to be writable at the group level. All users part of the same group can then write to the repository.
Your steps will then be something like:
mkdir test.git
git init --bare --shared=true test.git
When you use the git protocol, there's a daemon on the server that handles communication. In that case, the daemon and the repository can be owned by the same user.
You can find more details on setting up server-side git in the Git book.
| git: URL format to access remotely local git server |
1,372,926,892,000 |
Whenever I do anything with mercurial (e.g. hg status in a repository folder) I get a message saying:
extension 'git' overrides commands: gclear git-cleanup gimport gverify gexport
and the relevant part of my ~/.hgrc is:
[extensions]
hggit =
hgext.git =
Removing any one of these two lines makes the message go away, but - which of these should I remove and which should I keep?
I use Devuan ASCII 2.0 (but this is not a distribution-generated .hgrc file). Package versions:
mercurial 4.0-1+deb9u1
mercurial-git 0.8.11-1
git 1:2.11.0-3+deb9u3
|
The problem is that you are including hg-git twice.
hggit =
Is the recommended way
hgext.git =
Is the older way to enable an extension and is available in mercurial just for backwards compatibility.
I would suggest using just the first.
| Which hg-git line should I remove from my .hgrc file? |
1,524,057,191,000 |
I want to install the package from the following URL:
https://github.com/VegetableAvenger/ARPSpoofing.git
I have executed the command git clone https://github.com/VegetableAvenger/ARPSpoofing.git
and have changed to the directory using cd command.
Please, how do I install it?
|
To compile the source code you cloned, issue make in the project directory. To "install", you would copy the resulting executable ARP_Spoofing to any directory in your $PATH; or just leave it where it is and execute it from that directory as ./ARP_Spoofing.
Ideally you would read the C++ source prior to running the resultant executable.
| How to install packages from git |
1,524,057,191,000 |
I am working with the git filter branch for one specific task. It is using the sed command. When I use simple regex everything is working but for something more complex it is not. Maybe I have mistake in the regex or in the escaping chars. Please help.
git filter-branch -f --msg-filter 'sed -e "s/\[PEM-2233\] Merge branch 'master' of https:\/\/bitbucket\.test\.domain\.com\/rrr\/pem\/hello-world into feature\/PEM-2233-do-acceptance-tests/CHANGED/"' -- --all
The commit message I am trying to catch is
[PEM-2233] Merge branch 'master' of https://bitbucket.test.domain.com/rrr/pem/hello-world into feature/PEM-2233-do-acceptance-tests
|
You can't nest single quotes. The single quote before master closes the quoted string starting after --msg-filter.
As you can't include single quotes in a single quoted string, you need to end the string and properly escape the quotes:
branch '\'master\'' of http
| sed not catching the expected text |
1,524,057,191,000 |
I'm trying to set up visual mode mappings for quickly editing git's generated rebase list from when doing interactive rebase (e.g. git rebase --interactive upstream/master). In such you're presented with a text file that looks like this:
pick 12345678 commit message 1
pick 23456789 commit message 2
pick 34567890 commit message 3
What I'd like to do is to do <c-v> and select the lines I'd like to switch over to another rebase method, e.g. use <localleader>f to change from pick to fixup in the first word of the line. I'd like to make this a bit fault tolerant, so it doesn't do this for other lines, like comments and empty lines.
What I've tried doing is to do a :substitute with a regexp group to only pick up on valid words: (pick|reword|edit|squash|fixup|exec|drop). Here is what I currently have in .vimrc.
autocmd FileType gitrebase vnoremap <buffer> <localleader>p :s/^\(pick\|reword\|edit\|squash\|fixup\|exec\|drop\)/pick/<cr>
autocmd FileType gitrebase vnoremap <buffer> <localleader>r :s/^\(pick\|reword\|edit\|squash\|fixup\|exec\|drop\)/reword/<cr>
autocmd FileType gitrebase vnoremap <buffer> <localleader>e :s/^\(pick\|reword\|edit\|squash\|fixup\|exec\|drop\)/edit/<cr>
autocmd FileType gitrebase vnoremap <buffer> <localleader>s :s/^\(pick\|reword\|edit\|squash\|fixup\|exec\|drop\)/squash/<cr>
autocmd FileType gitrebase vnoremap <buffer> <localleader>f :s/^\(pick\|reword\|edit\|squash\|fixup\|exec\|drop\)/fixup/<cr>
autocmd FileType gitrebase vnoremap <buffer> <localleader>x :s/^\(pick\|reword\|edit\|squash\|fixup\|exec\|drop\)/exec/<cr>
autocmd FileType gitrebase vnoremap <buffer> <localleader>d :s/^\(pick\|reword\|edit\|squash\|fixup\|exec\|drop\)/drop/<cr>
Unfortunately the regexes don't match anything. I tried adding a \= at the end of the pattern to match 0 or 1 of any word in the group and it adds the replacement before the word it is supposed to substitute.
What am I doing wrong?
|
It's an escaping thing. Either always use \\| instead of \| or try
autocmd FileType gitrebase vnoremap <buffer> <localleader>p :s/\v^(pick\|reword\|edit\|squash\|fixup\|exec\|drop)/pick/<cr>
| How to substitute words in git rebase file |
1,524,057,191,000 |
I'm running the following command to download a single file from git:
git archive --remote=ssh://host/pathto/repo.git HEAD README.md
The contents of the file are directed to terminal, before I see the contents of the README I have some header information, that looks like this:
pax_global_header00006660000000000000000000000064131063477050014520gustar00rootroot0000000000000052 comment=502c8004562eab49c105b2e294d8806c735c13a1 README.md000066400000000000000000000002771310634770500123510ustar00rootroot00000000000000
My end goal is to redirect the file locally like so:
git archive --remote=ssh://host/pathto/repo.git HEAD README.md > README.md
How do I deal with the header information so I end up with files that don't contain the header as text?
|
I found that piping into tar xvf - solved the issue:
git archive --remote=ssh://host/pathto/repo.git HEAD README.md | tar xvf -
| Cat file dealing with header? |
1,524,057,191,000 |
I cannot clone any repository anymore.
$ git clone [email protected]:myaccount/myrep.git
Cloning into 'myrep'...
conq: repository does not exist.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
The thing is my ssh id_rsa key is still the same. I recreated it anyway, updated it in my BitBucket account's ssh keys, and the same error shows up when I try to clone my repository. I tried the very same procedure on another machine (redhat) and git clone worked. So there is something happening with git.
Then I went in another git versioned project:
$ cd share-repo
$ ls -a
./ ../ .git/ .gitignore* f1* f2*
I print the git config file:
$ cat .git/config
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = [email protected]:myaccount/share-repo.git
[branch "master"]
[user]
name = myaccount
I try a pull:
$ git pull -v
conq: repository does not exist.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Okay let's try a a push?
$ git push -v origin master
Pushing to [email protected]:myaccount/p2.git
conq: repository does not exist.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Huh? Git tries to push to repository p2? It should try pushing to share-repo... How in the hell is it trying to push to a repository which name is p2? Indeed, I had a repo named p2 this morning, but I deleted it from my BitBucket account while doing some tests, then I removed the related folder p2 from my computer. How did git retain information about p2? And above all, where is it stored, how can I reset it?
$ git remote -v
origin [email protected]:myaccount/p2.git (fetch) # ?!
origin [email protected]:myaccount/p2.git (push) # ?!
origin [email protected]:myaccount/share-repo.git (push)
Strange, as we saw previously the git config file only holds information regarding the repo share-repo. Also I tried locating the string p2 in the whole folder:
$ grep -Rin p2 ../share-repo/
# Nothing
I manually recreated a repository named p2 in Bitbucket. I tried to clone it:
$ cd ..
$ git clone [email protected]:myaccount/p2.git
Cloning into 'p2'...
warning: You appear to have cloned an empty repository.
Checking connectivity... done.
$ cd p2
$ cat .git/config
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = true
[remote "origin"]
url = [email protected]:myaccount/p2.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
$ git remote -v
origin [email protected]:myaccount/p2.git (fetch)
origin [email protected]:myaccount/p2.git (push)
origin [email protected]:myaccount/p2.git (push)
Okay, the git clone worked, but now it referenced two extra lines for the remotes, one of which is duplicated. Remember those extra lines when working with the repo share-repo? It's about those very first two lines which are still related to the old p2 repo I had deleted.
Let's try to push some changes:
$ git touch .gitignore
$ git add .gitignore
$ git commit -m "first commit"
$ git push -v origin master
Pushing to [email protected]:myaccount/p2.git
Counting objects: 3, done.
Writing objects: 100% (3/3), 216 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To [email protected]:myaccount/p2.git
* [new branch] master -> master
updating local tracking ref 'refs/remotes/origin/master'
Pushing to [email protected]:myaccount/p2.git
To [email protected]:myaccount/p2.git
= [up to date] master -> master
updating local tracking ref 'refs/remotes/origin/master'
Everything up-to-date
So git pushed to repo p2, and tried to do so a second time since the two repos have the same name and same location on my bitbucket account, so it obviously found that everything was up to date.
Now I could clone any repository I want, provided the repo p2 exists in my Bitbucket account. If I wanted to push some changes in let's say share-repo, it would work, but git would also try to push the same changes to the repository p2. That's quite a mess I got myself into and I don't know how to solve it.
To sum up, I had this morning a repository called p2 which I deleted from bitbucket, then I deleted it's folder from my computer. Since then, whichever git project I cd into, git remote -v shows me it has stored - somewhere - information related to the late repo p2, on top of the current repo I am working on. Git updating commands - clone, push, pull - won't work unless I create back this damn repo p2 on Bitbucket. Once I do so, git updating commands will apply the commands to the current repo I'm working on, as well as to the repo p2.
p2 is not the only repository I deleted today, so I am quite curious to know what happened here.
I will gladly take all the help I can get.
|
Solved. I am speechless. I had made a quick check for a ~/.git-whatever file using bash autocompletion (tab), it did not work so I blindly assumed the issue was somewhere else. Patrick's comment shed the light: I carefully checked using ls -a ~/, the ~/.gitconfig he wrote about really is here, and it holds the information regarding the remote:
$ cat ~/.gitconfig
[user]
name = myaccount
email = [email protected]
[remote "origin"]
push = [email protected]:myaccount/p2.git
And now I remember the cause for this: while experimenting I used the command git config --global remote.origin [email protected]:myaccount/p2.git and I changed other global configurations. I just did not understand what the --global did as I found no alteration in the repo/.git/config file.
Additional doc on git configuration: https://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration
| git retains remote information from a deleted repository |
1,524,057,191,000 |
This is my .gitconfig as it stands now :-
$ cat .gitconfig
[user]
name = Shirish Agarwal
email = [email protected]
[credential]
helper = cache --timeout=3600
This is in -
$ pwd
/home/shirish
Obviously I have obfuscated my mail id a bit to prevent spammers etc. from harvesting my mail id here.
But let's say I have another credential for another git site (private though) and I want to have it in the global configuration, both the username and the password so that when I pull from that site it doesn't ask me for the credentials anymore.
I am guessing this is possible, but how ?
|
I don't think that's possible. There are global configuration options and per-repository-options. If you use different email addresses in different repositories, you need to set them on a per-repository basis.
You can configure an individual repo to use a specific user / email address which overrides the global configuration. From the root of the repo, run
git config user.name "Your Name Here"
git config user.email [email protected]
You can see the effects of these settings in the .git/config file .
The default settings are in your ~/.gitconfig and can be set like this:
git config --global user.name "Your Name Here"
git config --global user.email [email protected]
Source
| How to have a global .gitconfig for 2 or more git repos? |
1,524,057,191,000 |
I am trying to achieve something along the lines of
diff -ywB --suppress-common-lines `git branch --merged prod-server` `git branch --merged test-server`
so that I can know the difference of what has been merged into my test server branch but not in my production server branch
But when I execute the command above my exit status is 2 (indicates error)
|
Use process substitution on bash:
diff -ywB --suppress-common-lines <(git branch --merged prod-server) <(git branch --merged test-server)
| how to pipe output from git commands into unix diff utility? |
1,524,057,191,000 |
I'm trying to build a custom kernel from a git repository on my Ubuntu virtual machine. I run the make command as follows :
sudo apt-get install vim libncurses5-dev gcc make git exuberant-ctags
mkdir -p git/kernels; cd git/kernels
git clone -b staging-next git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git
cd staging
cp /boot/config-`uname -r`* .config
make olddefconfig
make menuconfig
make
The build process ends with the following error.
drivers/staging/media/cxd2099/cxd2099.c: In function ‘slot_reset’:
drivers/staging/media/cxd2099/cxd2099.c:537:4: error: expected ‘;’ before ‘if’
make[4]: [drivers/staging/media/cxd2099/cxd2099.o] Error 1
make[3]: [drivers/staging/media/cxd2099] Error 2
make[2]: [drivers/staging/media] Error 2
make[1]: [drivers/staging] Error 2
make: [drivers] Error 2
How should I repair this error?
|
staging-next is, as of right now, currently broken, specifically f823182bc289 of staging-next is broken.
If you really want to use staging-next, check out fcf1b73d08cd, which is near the top and does compile.
| Compilation error when building a custom kernel |
1,524,057,191,000 |
The Codeswarm project provides a software project repositories visualization tool in Java. The software leverages the commit information from a log generated from a repository. The rendering illustrates the development efforts with an organic node visual render. Color is applied to specified file extensions to differentiate from one language to another, or from code to docs or images etc. This is a sample screenshot using the Ruby git repository:
Support is available for the following "types" of (D)VCS: Subversion, CVS, Git, Mercurial, Perforce, VSS, Starteam, Wikiswarm, Darcs.
It may be helpful to summarize the process involved with using this software from scratch:
Make sure we have the required software
apache-ant and what it pulls i.e. openj* and glu...
mesa-demos (the package which includes glxinfo)
git (or the software we need for repository access and cloning)
python 2.x (try "python"+tab to see what you have...)
a java JRE of some kind
Insure that the video driver is set up properly and OpenGL is set up correctly (if we ever want to use OpenGL) - try glxinfo | grep OpenGL to see if there are any errors.
Clone a repository with git clone somerepourl.git
Generate a log from the repository directory by running a specific git log command
Bring that .log file to our software directory in bin where we'll run a python script to convert it to a .xml file
Bring that output .xml file to our software data directory for use at execution
(1st run) Make sure our run.sh script where the java command is issued contains the appropriate components and library path
Make sure we configured sample.config properly in /data
Go to the top directory and execute ./run.sh, which compiles the software then runs it
So how do you set this up on a modern Linux platform?
|
Relevant directory structure
Once you have extracted Rictic's fork archive with unzip, take a quick look at the directory structure:
/code_swarm-master
|_bin <----convert tools
|_data <----activity.xml(converted .log file), sample.config
|_dist <----compiled code_swarm.jar
|_lib <----libraries and other .jar files required for java
|_src <----code_swarm.java source
/run.sh <----to run codeswarm
Clone a repository
Select a a project repository and then clone it locally:
git clone https://github.com/someproject.git
Generate a log file
Proceed to the newly created repository directory and generate a properly formatted git log like so:
git log --name-status --pretty=format:'%n------------------------------------------------------------------------%nr%h | %ae | %ai (%aD) | x lines%nChanged paths:' > activity.log
For long projects, there might be value in specifying a date range so as to focus on a specific time frame (for ex. --since=yyyy-mm-dd, but I have never been able to make this work). Or we can directly edit the xml data later on and strip it of the events we don't want.
Convert our .log file to a .xml file
We then bring this file to the bin directory and convert this with the provided python script(make sure to use python2.x):
python2.7 convert_logs.py -g activity.log -o activity.xml
This is where you would actually open the .xml file in a text editor for example and trim out lines you don't want. Now you can copy that .xml file to your data directory.
Sample.config configuration file
Rename the default sample.config file to another name, create an empty file, put the following in it, then save it as sample.config. The software reads this filename in the data directory by default so it's just convenient to use that. So you'll be able to simply press enter when the software asks for a .config file interactively(it does so every time):
# Input file
InputFile=data/activity.xml
ParticleSpriteFile=src/particle.png
# Basics - leave UseOpenGL to false until you manage to run this in software mode - if you use Virtualbox on a Wintel host, you may have issues so beware!
UseOpenGL=false
Width=800
Height=600
# FramesPerDay: for a short and focused range with high level of detail, use maybe 144. Or use 25 when there is no prior knowledge of how the project unfolds and maybe "2" for a "quick run" with long projects that haven't been constrained to a specific time frame. The smaller this value is, the faster the render goes. Performance may be a consideration when outputting frames to file. In snapshot mode, I have successfully used 720p with 12 frames per day
FramesPerDay=25
# Save each frame to an image?
TakeSnapshots=false
# Where to save each frame
SnapshotLocation=frames/code_swarm-#####.png
# You have to add extension blocks depending on the languages and types of files involved in the project:
ColorAssign1="C",".*(\.c|\.cpp|\.h|\.mk)", 255,0,0, 255,0,0
ColorAssign2="Python",".*(\.py|\.pyx)", 65,105,225, 65,105,225
ColorAssign3="CSharp",".*(\.cs|\.csproj)", 255,255,0, 255,255,0
ColorAssign4="Other Source Code",".*(\.rb|\.erb|\.hs|\.sql|\.m|\.d|\.js|\.pl|\.sh|\.lhs|\.hi|\.hpp|\.cat|\.inf|\.sys|\.dll|\.as|\.cmake\.java)", 255,99,71, 255,99,71
ColorAssign5="Documents/Images",".*(\.txt|\.html|\.tex|\.tmpl|\.css|\.xml|\.yml|\.json|\.rdoc|\.md|\.png|\.jpg|\.gif|\.jpeg|README|COPYING|LICENSE|AUTHORS|\.asciidoc|HACKING)", 138,43,226, 138,43,226
ColorAssign6="Tests",".*test.*", 153,255,255, 153,255,255
ColorAssign7="Localizations","(.*(\.mo|\.po))|(.*\.lproj.*)",110,200,90, 110,200,90
DrawNamesHalos=false
ShowUserName=true
MaxThreads=2
#BoldFont=
Font=SansSerif
FontSize=9
BoldFontSize=10
FontColor=245,245,245
Background=0,0,0
DrawNamesSharp=true
DrawNamesFuzzy=false
DrawFilesFuzzy=true
DrawFilesJelly=true
DrawFilesSharp=false
ShowLegend=true
ShowHistory=true
ShowDate=true
ShowEdges=true
EdgeDecrement=-8
FileDecrement=-3
PersonDecrement=-2
NodeSpeed=7.0
#FileSpeed=5.0
#PersonSpeed=2.0
FileMass=2.0
PersonMass=9.0
EdgeLife=140
EdgeLength=12
FileLife=1000
PersonLife=750
HighlightPct=8
PhysicsEngineConfigDir=physics_engine
PhysicsEngineSelection=PhysicsEngineOrderly
You can eventually compare those settings with the original sample.config file and adjust the parameters. Typos in this file are fatal for java.
Java
It's very important to set this up properly as it can be a real showstopper. When run.sh script is run, it validates if code_swarm.jar is present in dist and if not, it compiles it with ant. Once it's compiled, it gets executed. Unfortunately, the script is geared at MacOSX for execution. To remedy this, edit run.sh and put the following line while making sure other similar lines are commented(#):
if java -d64 -Xmx1000m -classpath dist/code_swarm.jar:lib/gluegen-rt.jar:lib/jogl-all.jar:lib/jogl-natives-linux-amd64.jar:lib/core.jar:lib/xml.jar:lib/vecmath.jar:. -Djava.library.path=lib/ code_swarm $params; then
You have to match what you have in the lib directory:
code_swarm-master/lib]$ ls -l
core.jar
export.txt
freebase
gluegen-rt-natives-linux-amd64.jar
gluegen-rt-natives-linux-i586.jar
gluegen-rt-natives-macosx-universal.jar
gluegen-rt-natives-windows-amd64.jar
gluegen-rt-natives-windows-i586.jar
gluegen-rt.jar
jogl-all-natives-linux-amd64.jar
jogl-all-natives-linux-i586.jar
jogl-all-natives-macosx-universal.jar
jogl-all-natives-windows-amd64.jar
jogl-all-natives-windows-i586.jar
jogl-all.jar
svnkit.jar
swing-layout-1.0.3.jar
vecmath.jar
xml.jar
Note opengl.jar is no longer present in a standalone fashion and is no longer required to make this work(see edit history).
(Optional)
Features. A few changes to the code_swarm.java file in src can improve some features. For instance there is a feature in the rendering called popular nodes. When the codeswarm renders, you can press "p" to show the popular nodes i.e. the files that get edited the most(touches). By default this appears at the top right of the render, but the color coding display appears to the top left. Altering the default behavior can make this appear automatically (so you press "p" to turn it off), while putting this underneath the color display to the left helps to regroup the information in one spot. To implement this find the following block of code and update the values accordingly (3, 105; 10, 105) - this is an updated version of that segment (result shown in Q):
/**
* TODO This could be made to look a lot better.
*/
public void drawPopular() {
CopyOnWriteArrayList <FileNode> al=new
CopyOnWriteArrayList<FileNode>();
noStroke();
textFont(font);
textAlign(LEFT, TOP);
fill(fontColor, 200);
text("Popular Nodes (touches):", 3, 105);
for (FileNode fn : nodes.values()) {
if (fn.qualifies()) {
// Insertion Sort
if (al.size() > 0) {
int j = 0;
for (; j < al.size(); j++) {
if (fn.compareTo(al.get(j)) <= 0) {
continue;
} else {
break;
}
}
al.add(j,fn);
} else {
al.add(fn);
}
}
}
int i = 1;
ListIterator<FileNode> it = al.listIterator();
while (it.hasNext()) {
FileNode n = it.next();
// Limit to the top 10.
if (i <= 10) {
text(n.name + " (" + n.touches + ")", 10, 105 + (10 * i++));
} else if (i > 10) {
break;
}
}
}
At the top of the source, you will find:
boolean showPopular = true;
Adding = true makes the popular nodes appear by default. This gets compiled only on the first run with ant during run.sh execution (unless you have java issues and doesn't get compiled at all). So if you modify the source code you must recompile if the code_swarm.jar is already present in the dist directory. If you want to restart the process (which takes a few seconds), just delete the already compiled version, modify the source, then run run.sh again to compile anew.
Running Codeswarm
Finally, now that we have the generated the activity.xml file, set up the sample.config and the modified run.sh script for our setup, we can run Codeswarm with:
./run.sh
Use "space" to pause the rendering and "q" to quit.
Enabling OpenGL rendering
Set UseOpenGL=true in your sample.config file.
| Codeswarm software project visualization: how do you set it up with opengl rendering on a contemporary 64bit Linux system? |
1,524,057,191,000 |
I didn't prevent same problem:
I don't use git rm projects.py and when i use :
git cp projectsTABTAB
projectsFindFrame.py projectsInsert.py
Also when i use:
git show a3ea2118bf1c5e2c6aa0974d0b6ff7415bd044ef
I prevent to content of projects.py file:
commit a3ea2118bf1c5e2c6aa0974d0b6ff7415bd044ef
Author: Mohsen Pahlevanzadeh <mohsen@debian>
Date: Wed Oct 9 04:21:14 2013 +0330
formValidators has been added, all of *_Insert component has been added to Projects() class.
diff --git a/projects.py b/projects.py
new file mode 100644
index 0000000..d76685b
--- /dev/null
+++ b/projects.py
@@ -0,0 +1,303 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+
+from tables import *
+from dbabslayer import *
+from languagecodes import *
+from PyQt4 import QtCore, QtGui
+
+
+try:
+ _fromUtf8 = QtCore.QString.fromUtf8
+except AttributeError:
+ def _fromUtf8(s):
+ return s
+
+try:
+ _encoding = QtGui.QApplication.UnicodeUTF8
+ def _translate(context, text, disambig):
+ return QtGui.QApplication.translate(context, text, disambig, _encoding)
+except AttributeError:
+ def _translate(context, text, disambig):
+ return QtGui.QApplication.translate(context, text, disambig)
+
+
+
+
+class Projects(QtGui.QMainWindow):
My Question is : Why i can't do git cp projects.py ? But it's to be.
|
From your Tab completion results, it looks like projects.py isn't in the current checkout. Or at least, it isn't in the current directory. Say git ls-files | grep projects.py to find out if Git believes the file exists here and now, in your checkout.
If ls-files doesn't show the file, you need to find out which branch it is on.
If you cannot remember where it is, I recommend that you use a Git GUI to explore your tree, past and present. Once you know when the file existed, you will know where to go to copy it from.
| a file to be in git or not to be? |
1,524,057,191,000 |
I'm using yocto to build my custom Linux distribution. I need to add hiredis to my distribution. hiredis is a minimalistic C client library for the Redis database, and I need it to access Redis by a C application.
The recipe hiredis_0.14.0.bb
In my yocto build system there is the recipe hiredis_0.14.0.bb stored in the folder meta-openembedded/meta-oe/recipes-extended/hiredis so in the meta layer meta-openembedded.
The content of the recipe is the following:
DESCRIPTION = "Minimalistic C client library for Redis"
HOMEPAGE = "http://github.com/redis/hiredis"
LICENSE = "BSD-3-Clause"
SECTION = "libs"
DEPENDS = "redis"
LIC_FILES_CHKSUM = "file://COPYING;md5=d84d659a35c666d23233e54503aaea51"
SRCREV = "685030652cd98c5414ce554ff5b356dfe8437870"
SRC_URI = "git://github.com/redis/hiredis;protocol=git \
file://0001-Makefile-remove-hardcoding-of-CC.patch"
S = "${WORKDIR}/git"
inherit autotools-brokensep pkgconfig
EXTRA_OEMAKE = "PREFIX=${prefix} LIBRARY_PATH=${baselib}"
# By default INSTALL variable in Makefile is equal to 'cp -a', which preserves
# ownership and causes host-user-contamination QA issue.
# And PREFIX defaults to /usr/local.
do_install_prepend() {
export INSTALL='cp -r'
}
The Git Fetcher download the version 0.14.0 of hiredis
If I execute the command:
> bitbake hiredis
the hiredis code is fetched by GitHub and correctly compiled. The version on the code downloaded from GitHub is the 0.14.0, while the SRC_URI is set to:
SRC_URI = "git://github.com/redis/hiredis;protocol=git \
file://0001-Makefile-remove-hardcoding-of-CC.patch"
This value for SRC_URI means that is using the Git Fetcher and are not specified parameters branch or rev and this means that the values of this parameters is master.
The only reference to version 0.14.0 is in the name of the recipe (hiredis_0.14.0.bb) so it is chosen the version 0.14.0 because the value of the PV variable is 0.14.0 (the PV value is set by the name of the recipe).
My question
Why the fetched version of hiredis library is 0.14.0 and not the latest?
|
As @Kusalananda tells in his comment:
the release of hiredis downloaded from GitHub is selected by the commit hash assigned to the variable SRCREV.
For example to fetch and compile the release 1.0.1 of hiredis I can add to the folder my-meta-layer/recipes-extended/hiredis a file hiredis_%.bbappend and, in it, set the value of SRC_REV equal to the commit hash of the release 1.0.1 (that is 8d1bfac4640fe90cd6f800d09b7f53e886569b98).
In the case of the recipe hiredis_0.14.0.bb showed by the question I need also change the value of the variable SRC_URI.
The content of the added file hiredis_%.bbappend is showed below:
# SRC_URI for release 1.0.1
SRC_URI = "git://github.com/redis/hiredis;protocol=https;branch=master"
# Commit Hash of release 1.0.1
SRCREV = "8d1bfac4640fe90cd6f800d09b7f53e886569b98"
inherit cmake
Description of the bbappend file
by the SRC_URI value I have set the value of parameters protocol=https;branch=master of the Git Fetcher (instead in the original recipe their values were protocol=git and branch is not set)
set SRCREV equal to the commit hash of release 1.0.1
add the instruction inherit cmake because the release 1.0.1 uses CMake
My solution not work for all release of hiredis
I think that my solution could be a general solution of the problem presented in the question for many yocto recipes, but in the case of the hiredis it doesn't always work.
I have tested the solution for some releases with the following result:
ok for release 0.14.0, 1.0.1, 1.0.2
not work for release 0.14.1
| In a yocto recipe, what selects the release to download from the GitHub repository? |
1,524,057,191,000 |
I'm strugling with a script to backup config files from root folder that copies the file inside a folder in myuser directory, reproducing the original path structure, adds the file to a git repo and commits changes. The script take the path of config file to be backed up as argument:
BU.sh /etc/apt/sources.list
Apparently the first run of program work correctly on a freshly cloned repo with only README.md, but, in the following runs, the git commands seems to have no effects.
The script is this(with some debug info added):
#! /bin/bash
#
set -x -e -u
export GIT_DIR=/home/myuser/config-BU/.git
export GIT_WORK_TREE=/home/myuser/
#echo "file NOT in USER DIR, is NOT symlink";
ls -l config-BU
mkdir -p /home/myuser/config-BU/"${1%/*}";
ls -l config-BU
sudo install -o myuser -g myuser -m 660 "$1" "/home/myuser/config-BU$(realpath $1)";
ls -l config-BU
sudo -k;
git status
git ls-files
git add "/home/myuser/config-BU$(realpath $1)";
git ls-files
git commit -am "adding file inside BU autom: file NOT in user folder" -m "$(realpath $1)";
git log
Two runs of the command result in:
MYPROMPT>:~$ ./cp2bu2_badpart.sh /var/log/faillog
+ export GIT_DIR=/home/myuser/config-BU/.git
+ GIT_DIR=/home/myuser/config-BU/.git
+ export GIT_WORK_TREE=/home/myuser/
+ GIT_WORK_TREE=/home/myuser/
+ ls -l config-BU
total 4
-rw-r--r-- 1 myuser myuser 27 Jul 7 19:40 README.md
+ mkdir -p /home/myuser/config-BU//var/log
+ ls -l config-BU
total 8
-rw-r--r-- 1 myuser myuser 27 Jul 7 19:40 README.md
drwxr-xr-x 3 myuser myuser 4096 Jul 7 22:25 var
++ realpath /var/log/faillog
+ sudo install -o myuser -g myuser -m 660 /var/log/faillog /home/myuser/config-BU/var/log/faillog
[sudo] password for myuser:
+ ls -l config-BU
total 8
-rw-r--r-- 1 myuser myuser 27 Jul 7 19:40 README.md
drwxr-xr-x 3 myuser myuser 4096 Jul 7 22:25 var
+ sudo -k
+ git status
On branch main
Your branch is up to date with 'origin/main'.
Changes not staged for commit:
(use "git add/rm <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
deleted: README.md
Untracked files:
(use "git add <file>..." to include in what will be committed)
==LIST OF FILES IN MY HOME DIR==
no changes added to commit (use "git add" and/or "git commit -a")
+ git ls-files
README.md
++ realpath /var/log/faillog
+ git add /home/myuser/config-BU/var/log/faillog
+ git ls-files
README.md
++ realpath /var/log/faillog
+ git commit -am 'adding file inside BU autom: file NOT in user folder' -m /var/log/faillog
[main 2487ec3] adding file inside BU autom: file NOT in user folder
1 file changed, 2 deletions(-)
delete mode 100644 README.md
+ git log
commit 2487ec3857d355313971f2a45ba7d318870bc219 (HEAD -> main)
Author: myuser <myemail>
Date: Fri Jul 7 22:26:41 2023 +0200
adding file inside BU autom: file NOT in user folder
/var/log/faillog
commit 84112df2c48137f247af78497e416182f0e0c24c (origin/main, origin/HEAD)
Author: Pippetta87 <[email protected]>
Date: Thu Oct 13 03:59:13 2022 +0200
Create README.md
MYPROMPT>:~$ ./cp2bu2_badpart.sh /etc/X11/rgb.txt
+ export GIT_DIR=/home/myuser/config-BU/.git
+ GIT_DIR=/home/myuser/config-BU/.git
+ export GIT_WORK_TREE=/home/myuser/
+ GIT_WORK_TREE=/home/myuser/
+ ls -l config-BU
total 8
-rw-r--r-- 1 myuser myuser 27 Jul 7 19:40 README.md
drwxr-xr-x 3 myuser myuser 4096 Jul 7 22:25 var
+ mkdir -p /home/myuser/config-BU//etc/X11
+ ls -l config-BU
total 12
-rw-r--r-- 1 myuser myuser 27 Jul 7 19:40 README.md
drwxr-xr-x 3 myuser myuser 4096 Jul 7 22:27 etc
drwxr-xr-x 3 myuser myuser 4096 Jul 7 22:25 var
++ realpath /etc/X11/rgb.txt
+ sudo install -o myuser -g myuser -m 660 /etc/X11/rgb.txt /home/myuser/config-BU/etc/X11/rgb.txt
[sudo] password for myuser:
+ ls -l config-BU
total 12
-rw-r--r-- 1 myuser myuser 27 Jul 7 19:40 README.md
drwxr-xr-x 3 myuser myuser 4096 Jul 7 22:27 etc
drwxr-xr-x 3 myuser myuser 4096 Jul 7 22:25 var
+ sudo -k
+ git status
On branch main
Your branch is ahead of 'origin/main' by 1 commit.
(use "git push" to publish your local commits)
Untracked files:
(use "git add <file>..." to include in what will be committed)
==LIST OF FILES IN MY HOME DIR==
nothing added to commit but untracked files present (use "git add" to track)
+ git ls-files
++ realpath /etc/X11/rgb.txt
+ git add /home/myuser/config-BU/etc/X11/rgb.txt
+ git ls-files
++ realpath /etc/X11/rgb.txt
+ git commit -am 'adding file inside BU autom: file NOT in user folder' -m /etc/X11/rgb.txt
On branch main
Your branch is ahead of 'origin/main' by 1 commit.
(use "git push" to publish your local commits)
Untracked files:
(use "git add <file>..." to include in what will be committed)
==LIST OF FILES IN MY HOME DIR==
nothing added to commit but untracked files present (use "git add" to track)
As you can see the second run do not add file to git repo and last git log is not executed: the git commands after git status seems to be ignored.
Best Regards
|
You start your script with:
export GIT_DIR=/home/myuser/config-BU/.git
export GIT_WORK_TREE=/home/myuser/
Your working dir should actually be /home/myuser/config-BU.
That's why when you run git status you see:
Changes not staged for commit:
(use "git add/rm <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
deleted: README.md
It can't find README.md in your GIT_WORK_TREE (/home/myuser/README.md), so it thinks that this file was deleted.
Then when you commit your change, you see again that it deletes README.md from the index:
git commit -am 'adding file inside BU autom: file NOT in user folder' -m /var/log/faillog
[main 2487ec3] adding file inside BU autom: file NOT in user folder
1 file changed, 2 deletions(-)
delete mode 100644 README.md
| Problems with git commands in a bash script on runs following the first |
1,524,057,191,000 |
I want backup some config file in a git repo inside my home; earlier I've been using work-tree=/ but i don't like this solution anymore.
Now I'm trying to create a script that take a given config file, copy it inside my backup repo, add it to git, and do a commit. My attempt is:
cp --parents $1 /home/myuser/config-BU/
chown myuser "/home/myuser/config-BU/$1"
#exit sudo
su myuser
git --git-dir=/home/myuser/config-BU/.git/ --work-tree=/home/myuser/ add "/home/myuser/config-BU/$1"
git --git-dir=/home/myuser/config-BU/.git/ --work-tree=/home/myuser/ commit -am "adding file inside BU autom" -m "$(realpath $1)"
I call it with:
sudo -u myuser -E bash "/home/myuser/cp2bu.sh /etc/apt/sources.list"
and got this:
error: XDG_RUNTIME_DIR is invalid or not set in the environment.
[Line 1096] Unable to connect to the compositor. If your compositor is running, check or set the WAYLAND_DISPLAY environment variable.
[1]+ Termine 253 swayidle -w timeout 300 'swaylock -f -c 000000' timeout 600 'swaymsg "output * dpms off"' resume 'swaymsg "output * dpms on"' before-sleep 'swaylock -f -c 000000'
So the big question is: How "exit" sudo after I copied config file? Or how can I re-arrange script to avoid this problem?
Should I use sudo -k?
But even using the above solution (with sudo bash -c "/home/myuser/cp2bu.sh /etc/apt/sources.list") I don't have the files added into git repo,and don't see the commit in git log.
Any suggestions?
Best regards
|
You easily end up in quoting hell when trying to pass complex commands to something like su or sudo.
In this case I guess the easiest approach is to use sudo within the script only:
#! /bin/bash
[[ $1 =~ / ]] && mkdir -p /home/myuser/config-BU/"${1%/*}"
sudo install -o myuser -m 600 "$1" "/home/myuser/config-BU/$1"
git --git-dir=/home/myuser/config-BU/.git/ --work-tree=/home/myuser/ add "/home/myuser/config-BU/$1"
git --git-dir=/home/myuser/config-BU/.git/ --work-tree=/home/myuser/ commit -am "adding file inside BU autom" -m "$(realpath $1)"
| bash script to backup config file inside git repo reproducing its path |
1,524,057,191,000 |
I have a very specific use case. The DesignSync versioning system we use replaces files with their symlink to the remote repository when we check-in a file.
Since I use git locally to version my changes before checking it in, I don't want "replacing a file with a symlink" or vice versa to be considered a change in the file - as long as the content of the file/symlink is the same.
Is there any way to achieve this?
|
I don't think there's a "beautiful" way forward here, aside from moving away from that symlink methodology (I don't know whether that's a feature DesignSync has. You might need to hope Dassault sees the errors in its ways.) You're just trying to use two different code versioning tools, with contradicting approaches, and it seems logically impossible to me to reconcile these two perfectly.
You need to use git on the actual files – otherwise, it won't see any changes when you change the contents. You need to respect DesignSyncs symlinking.
There's three ways I saw, but I tried and can rule out the first:
Using .gitattributes, you could have a "smudge" and a "clean" filter that replace symlinks with the files symlinked to, and vice versa, on commit and checkout. Doesn't work, since symlinks get no special treatment in .gitattributes
You can write a pre-commit script that looks to replace all symlinks with the original files, copied from the DesignSync-managed "upstream".
You could write a FUSE file system that gives you a second "view" at the DesignSync repository, in which the symlinks get replaced by the actual files symlinked to. You bind-mount in a .git repository directory and manage your files in git that way.
Neither way is going to be painless. I'll be honest, you'll have to pick one source control system to use at a time; what you're trying to do just makes me feel uneasy.
I honestly think the easiest way might be to not do anything special – keep your local git repository as is, and have a separate checkout whenever you feel like checking in changed files to DesignSync. Git can check out your repository into arbitrary locations! Whenever you need to pull in changes from DesignSync into your git repository, I'd honestly just cp -L ("following" the symlinks) a fresh DesignSync checkout into your git repo.
| How can I make git treat symlinks as a file? |
1,678,812,749,000 |
This is the completion code in my .zshrc:
autoload -U compinit
zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}'
zstyle ':completion:*' menu select
zmodload zsh/complist
compinit
_comp_options+=(globdots) # Include hidden files.
I've been having a problem with the autocompletion when i use an alias:
config='/usr/bin/git --git-dir=$HOME/.local/share/dotfiles --work-tree=$HOME'
This problem has been discussed and explained before (please check them they explain the problem better than i can) here and here, and the only reason that I'm mentioning this even though it's been discussed is because none of the solution work, and because there's these line of changes to the _git completion script that weren't there before:
(( $+opt_args[--git-dir] )) && local -x GIT_DIR=${(Q)${~opt_args[--git-dir]}}
(( $+opt_args[--work-tree] )) && local -x GIT_WORK_TREE=${(Q)${~opt_args[--work-tree]}}
These lines made the alias function but in one case only if the alias is written like i posted above it doesn't work but if the $HOME variables were replaced with ~ it works perfectly as it should the only problem is that if i do make that replacement the alias wouldn't work anymore and gives this error: fatal: not a git repository: '~/.local/share/dotfiles'
|
After investigating a bit I found out that it's a problem with the expansion of the $HOME variable, but the solution suggested here works perfectly, I just replaced --work-tree=$HOME with --work-tree ~ and it worked.
| Zsh autocompletion for git bare repos |
1,678,812,749,000 |
I have a CSV file
:> file save.dat
save.dat: CSV text
This is made of lines like this:
2022-12-31,08:36,meer,CLOSE_WRITE|CLOSE,/hd2/projects/inv,900.Oliver.odt
My local file has a line that differs from the MASTER version by a single line that is guaranteed unique through the algorithm that generates the lines.
Git refuses to merge the files as I see it often does well with source code: includes a marker in the file with a version identifier.
Why is git not merging this file in that way. What can I do to force the merge? In the current situation I have to perform the merge manually through a busy process.
|
After comment by @Aaron D.Marasco I added the .gitattributes file to the project root directory.
The problematic file is named save.dat so the attributes file wants this
*.dat text
| git: merge of csv files |
1,678,812,749,000 |
When I print a file from git using the command, there are edge cases:
git diff --no-renames --name-only
Edge case 1: spaces
(added --diff-filter=D for illustrative purposes)
# format 1: unquoted
$: touch 'foo bar.txt'
$: git add 'foo bar.txt'
$: git commit -m 'test'
$: rm 'foo bar.txt'
$: git diff --no-renames --name-only --diff-filter=D
foo bar.txt
Edge case two: special chars
# format 2: quoted
$: touch 'foo
bar.txt'
$: git add 'foo$\nbar.txt'
$: git commit -m "test"
$: rm foo$'\n'bar.txt
$: git diff --no-renames --name-only --diff-filter=D
'foo\nbar.txt'
Neither foo bar.txt nor 'foo\nbar.txt' can be submitted to rm for deletion as-is. And, they are inconsistent.
Is there a way to control how git forms the file names so that they can be removed by rm as is?
|
git diff --no-renames --name-only -z | xargs -0 -I {} sh -c 'rm -- "{}"' is what I went with.
| Control the way git prints file names so that they can be passed to rm? |
1,678,812,749,000 |
I recently learned about pass git integration, which allows to sync my passwords with a remote git repo. Which I instantly didn't hesitate to configure.
So then I decided to clone this repo on another computer (with another GPG key installed) and try to access the passwords. It however complained:
pass myaccount
gpg: decryption failed: no secret key
I guess that comes from the fact that I have another GPG key installed, not the one I encrypted my passwords with (I use the same GPG key ID though).
So, how do I access those passwords without transferring private GPG keys from the original machine to this one? I of course know the passphrase, and can transfer public ones if needed.
Or am I required to copy over the whole keyring?
Thoughts...
Now after writing this post, I think I'm closer to understanding how it works. So basically the keys I can find in ~/.gnupg aren't just keys - they are encrypted keys. Encrypted with the passphrase. And so it's relatively safe to copy them to another machine. Is it correct?
|
I still haven't tried it myself, but pass should be able to encrypt passwords for multiple GPG keys, so transfer the public key from the second computer to the first, and run pass init <id-of-GPG-key-1> <id-of-GPG-key-2>, then pass should encrypt all passwords in your store that aren't encrypted for those two keys for them, and (when synced, that's something git is good for) then they should be useable on both computers.
If you can't remember the id of the key that passwords are currently encrypted for, you can look in <password-store>/.gpgid.
| How do I access my passwords from `pass` from another computer without transferring private GPG keys? |
1,678,812,749,000 |
I need a small help in writing an ansible playbook. I have written the below till now which is listing all files with config basically. but I need to filter out the files which are basically .git/config
- hosts: all
connection: local
gather_facts: no
tasks:
- name: "Serching old git URL"
become: true
become_user: root
find:
paths: builds
file_type: file
recurse: yes
patterns:
- config$
use_regex: true
contains: 'atlgit-01.us.manh.com'
register: configfiles
- debug:
msg: "{{configfiles.files | map(attribute='path')| list }}"
Below is the 0utput
"/builds/v2020/app/db-upgradesetup-to/.git/config",
"/builds/v2020/app/db-upgradesetup-to/environments/configure/configureEnv.xml",
"/builds/v2020/app/db-upgradesetup-from/.git/config",
"/builds/v2020/app/db-upgradesetup-from/environments/configure/configureEnv.xml",
"/builds/v2020/app/db-upgradesetup-from/ui/help/Content/Resources/images/config.gif",
"/builds/v2020/app/db-upgradesetup-from/ui/help/Content/Resources/images/configure_button.gif",
"/builds/v2020/CI/source/dockerqa/.git/config",
"/builds/v2020/CI/source/docker_ci/.git/config",
"/builds/v2020/escrow/.git/config"
Thanks you for the help
|
There is an excludes option to the find command that I think will do what you want.
excludes: '.*./.git.config'
https://docs.ansible.com/ansible/latest/collections/ansible/builtin/find_module.html
| Ansible find files only if contains particular string |
1,678,812,749,000 |
I would like to create separate files based on the first chromosome mentioned in the header line. There are 24 chromosomes mentioned in the header line and their sequences are mentioned in the next 2 lines. The file architecture is:
header
human sequences
other genome sequences
However, all the chromosomal sequences are merged within a single file that I want to split into individual chromosome files along with their respective sequence pairs. I created a Python script for this but uploading the big merged file on the cluster takes a huge amount of time and often leads to a connection error. So, I want to do it using a Bash script.
The idea is to search for 'chrY' (or any chrome name) on the 2nd column of the header line and then paste that header line along with their 2 following sequence lines into a separate file.
2057524 chrY 68 170 chrX 23685 23787 - 4125
TCCAGACTACCAGACACAAGACATTACACATTGTAATGCATTAAATGCATAGTTTTAACAGTAATAATTTAAAAGAGATTTAGAATTTTATAATGTTTGGAAA
TCAAGGCCCCGGGCTACCTGACATTACCCTCATTAATGCATGAAATGCAGAATATTAACATGAGCAATTTAAGATGAACTTAAGATTCTGTAATGTTTAGAAA
Details:
2057524 chrY (human chromosome) 68 170 chrX (other genome chromosome) 23685 23787 - 4125 -> header line
TCCAGACTACCAGACACAAGACATTACACATTGTAATGCATTAAATGCATAGTTTTAACAGTAATAATTTAAAAGAGATTTAGAATTTTATAATGTTTGGAAA (human sequence)
TCAAGGCCCCGGGCTACCTGACATTACCCTCATTAATGCATGAAATGCAGAATATTAACATGAGCAATTTAAGATGAACTTAAGATTCTGTAATGTTTAGAAA (other genome sequence)
For testing:
2057521 chr10 57211219 57211230 NW_007726181v1 1018288 1018299 + 575
CTGGGCACTATG
CTGAGCGCGGTG
2057522 chr2 57211231 57214400 NW_007726181v1 1018406 1021615 + 116172
GTTTtgagcttgt----acccagcgctgcttttgccttgctctgtgaccccaggcaagctgcctcacctctctgggccagtttccccat-cgtacagtggTGCTGCACACCCTGGCCCTGGCCC-CGAGGTGGCTGGGAGGTGGCTCCTCAAACAGCCGCTTTCTCATCAGTGCCCGGTGCTGGGT-CAGGGATCGACTGAGGCTCT--GAGCTAACTAGGAAACACAGTGGCCTTG--GAGGGCTGGGGAGTGTCATGGGGGTG---GGGACAGGGAGCCACCGGTCGCATGTGACTGAACTCTT-----------------CACCCCAGTCTGTGGCTTTCCCGTTGCAGTGAGAGCCACGAGCCAAGGTGGGCACTTGATGTCGGATCTCTTCAACAAGCTGGTCATGAGGCGCAAGGGTAGGAGGCAGGGCCGCTGCCCGCCCTGGGTCGGCACCT---------------TGTAATTCTGTCCTGCCTTTTTCTTCCTGTATTTAAGTCTCCGGGGGCTGGGGGAATCAGGGTTTCCCACCAACCACCCTCACTCAGCCTTTTCCC-TCCAGGCATCTCTGGGAAAGGACCT------GGGGCTGGTGAGGGGCCCGGAGGAGCCTTTGCCCGCGTGTCAGACTCCATCCCTCCTGTGCCCCCACCGCAACAGCCACAGGCAGAGGAGGACGAGGACGACTGGGAATCCTAGGGGGCTCCATGACACCTTCCCCCCCAGACCCAGACTTGGGCTGTTGCTCTGACATGGACACAGCCAGGACAAGCTGCTCAGACCTGCTTCCCTGG-GAGGGGGTGACGGAACCAGCACTG---------TGTG-GAGACCAGCTTCAAGGAGCGGAAGGCTGGCTTGAGGCCACACAGCTGGGGCG---GGGACTT-CTGTCTGCCTGTGCTCCATGGGGGGACGGCTCCACC--------CAGCCTGCGCCACTGTGTTCTTAAGAGGCTTCCAGAGAAAACGGCA-CACCAATCAATA-----------AAGAACTGAGCAGAAACCAACAGTGTGCTTTTAATAAAGGACCTCTAGCTGTGCAGGATGCAAACGTCTCGGGGTCAGTGACTGCCTCCTGCCCCTGTTGGTCCCTAGGCAGTGGGGGCAGAAGCTCCCAGCTGACCTG------TTTCTCTGGGAGAGAAGGGCAGTCAGCAGGGGCAGCTGTTGCAGATGGGAGGAATAG--------TCTCCCACA----AAAAAGGTTTCAGTGACAGACACGGGGTCTCTAAAAATAGTCATGCTGAGAGCCCAATGGCCCTTGGCACAATTGCTGGTGTTGGGGTAGAAGATGTCTTGGAGTTTGCTCAAGTGGTTGAGAGGGAGGGAGGTGCCATCAACTT---GGAGGAACTGGCACCAAGCCAGGGAGATAGAAATCCAGGCAAGGCTGTGGGGCAGGTTAGGGAGCAAGGCTGCAGGGGTGACTCAGGAAGAAGGTGGGGGAGGTGACAAGCCCCCAGGCAGGGGCCCTGTGGCC-------------ATGGGGATCTTTTTAAATTGAGACTAGGGGGTGAATAGTCCAGGGCAGCTAACTTTAGTTATTATAGAAAG-GGCAGTAGCAGATGGGTCTG-CTCCGTCTCGCTTCTAAGAAGGTGG---------------GCAGGACAAATGGCAGCCTCCTGCAGAGGCCCAGTGAGAAGCCTGGCCC-------TCGGCCAC-----ACAGGATGGAAGACAGATTGGATTCCACAGAGGGGAGCTGCCCTGGGAAGATCTCACGGATGGCCAGGACCCACCATTTCTTCGGGGTTCCCCT-GTTTTCTCCAACGGGCACTAATGCCTGTGCCTGGGTCCTGGCAACAC----------------------TCTGGACTCCACACTCT--TCTGGGTTTCACCTTTGTA-GCAGGATCCCTGCAGATCAGGCCCATGACAAACACCGTCTCCAGCGGGCAGAGCAAAGGAAGGGCGCAGCGCCAGGCAGTGGTGCAGCTGCCTGTCAGGAAGAGGCCTACTTCT---GGTGAAACTGGGCAGAC---AAAAGGCAGTGAGAAATGTGATCTCGGGGTGGTGGAGGCTC-TAGGGAAAGGAAAAGGCAGGAGTGAACTTCCACACAGCAGCAATGGCAGAACCAAAGGTGGCTTTGACCTCCACGAGGGCTCAGATCCAGGCCAACAGCTTGTCCAGGACAGGGTGCCGGGTGTATCACTAATCCAGGAGCACTATGCTGGCAGAATCCCTTTGGTGCCTGATGGCCCTGCCTTCGTGGGAACAGAGGCTAAGGCTTTGAGTTACAGCTGCCTCCCCAACAGTGCATCCCCTTCTCCTTCCTCAGCCTCAGGTAGGAGACAGGGCAGGCAACCCCCCTTTCCTCTTCTCCCCTTCTCCAGCCCCTGTCTGTCCACCCAGCTGGAGGCAG--CCAGGCTTGCCTATGGACTGGTTGACAGCCTTCATGCACAGGTTCTCCACCAGAGCCTTTCTTGGGGGCCCCTGGCT--GGGCTCTGAGCTGGGAGTGAAGGGGATGACCCATGCGGACTGTTTGCTGC-------------TTGTAGCTTTCCCTGGGA-AAGACTCTGCCAGGCCTTGGAGCCAGACCAGGAGGCTTTATAGGCCACTGCAAGCAGCAGGGCTCCAGATGACATCACAGGGAATATCAAGAGGGTGTGGAGGGGCATCGAAGCCTCTCCAGGAG---ACAG----GAGAC---GCCGGCCCAGTAGAGCCCTAGGGGCGACGCCACTCCCACTCACTGTCTACTCTCCTCTCACCTCTGCAACACTGGGGACACTCACAAGATTGTGATCCAAGTCGGCCGTCGTCTTCTGCAGCTCTGGAGACCTGATGCTGGGGAAGGGCATGCCTGGCATCACCACACACCTGGGAGGAGACAGGAGCCTG-GGGCCGGTGG---------------------GCCCACACATCACCAGCTGCTCCGTTCTACCATTTCTTCAGCCCTCTTGGCTGTGC-CTGCGGCTCTGCCCCTCCCCTCTCTGCACCTACCACCCAGAGAGGGCTTGTTGAGCTCAGAGATCCCACCTAGGCCAATCCACTGGGTTCTGTGGCAGCGATGGCCTGCCTGATCTTCCACCTGCTCTCCCAGGGCCAAAGCCAGACCTGCTGAGCCCCTCCC--TCCAGCCGGCTGGT-CTGAGCAGTCACAGCCCGGCTTTGGGCTCCGATGGCAGCAGATGGCAGGTAGGGGTCCAGCTGCTGG-AGCGAGGGCCGGCCACGTATCACAG-CCAAGGAGATGAGCACAAG--CACTACTTACTGGCCTAGGTTGTCAGAGAAGTTGATGCTCTCACTCATCTTTCCTCCAATC
gtcctgagtttgccaaggcccagctctgcttctgacttgtcctgtg-----agacaaagtgcctaacgtctttgggccagtttcctcatccccacagtggggctgcaca-cctgcccgtgtcttacaggatggccgtgatgt------tca-----CCATTTTCTTAT-AGTACCCACTGCCAGATACACGGACAGACCAAAGCTCCCAGAGCTCA-TGGTGAACAT-GTGGCTGTGGAGAGGGCTGGGGACTGTTGCAGGGGCAAGTGAGCCAAGAGGGCACTGG-CGACTGGGCCTGGAGCCTCCCGACTTGGCCCCCGCACCCTCCCACCTGCAGCTTTCCTCTTGCAGTGAGAGCCACAAGCCAAGGTGGAGACCTGATGTCAGATCTCTTCAACAAGCTGGTCATGAGGCGCAAAGGTAGGAGGCAGAGGGGCCGCC--TTCAGGGCAGGGGCCTCAGGGTGTCCTGCAGTGTACTTCTGTTCTGCCTCTTTCTTCCTGTTTTTAAATCTTCAGGGGCTGTGTGACCTGGGGCCTCCATACACCCTCCCTCA--CAGCCTTTTCCCTTCCAGGTATCTCCGGGAAAGGACCTGGAACAGGGGCCAGCGAGGGGCCAGGAGGAGCCTTCGCCCGAATGTCAGACTCCATCCCGCCTCTGCCTCCCCCACAGCAGCCAC---CGGGAGAGGACGAGGATGACTGGGAATCCTAGGGGTCT-CAGCACTCCTTCCTCCCCCAACCCAGACTTGGGCTGTGGCCCTGAGACAGACACAGCTGGGACA--------------GCCCCCTTGGTGAGACAGGGATGGTG-CAGGACTGCCCTACGTCTGTGCTGGGCCTTCTTCAGGGAGCGGGTAGGTTGCATGAAACCATAAGTGTGGGGTGGGAGGGGCTCGCTCTCCACCTGTGCCCCACCGTGTGCCTGCTCTACCCACCCCTTCAGCGTGTGCTCCTCTTCCCGAAAGAGACT--CGAAGAAAACAGCACCATGAATCAATAAAGGACGATGTAAGAACTGAGCATAAACCAACAGTGCACTTTTAATTAAGGAGTCAAGGCTGGGTGGCTTGCAAACATCTGAGAACCAGTGACTG--TCCTGCCCC-GTGGGTCTCCAGGCAAT-GGGGCAGAACATCTGAGTGGACCAGGGCCCCTTGCACTGGCTCGAAGGTGCAGTCAGCAGGGGCAGCTGCTGTGGATGGGAGGGAGGGAGGGAGATGTTCCCACGGGATAAAGATGTCTCAGTGACAGACATGGGGTCTCTAAAAATAGTTGTGCTGAGAGCCTAATGGCCCTTGGCATAATTGCTGATGTCAGGGTAGAAGGTGTCTTGGAGTTTGCTCAAGTGCCTGAGAGGGAAGGAGGTGCCATCAACTTGGAGGAGGAATGGGAGCCAAGCCAGAGAGA-AAAGCCCTGCGCGGAGCTGTGGAGCAGACCA--GAGCACAGCTG-----------------------------------AGGCTGGCAGG-AGGAGCCGTGTGGACAGCAGAACTAGAAATGGGGAACGTTTTGAGT------------GTGAAATGTCTAGAACAGCTCATTTTAGCTAGGATGAACAGAGGCAG-----GATGGGCCTGTTTCCATCGGACCTCTGAGAAGGTGGCTACTGAGAAAACATGCAGGACAGAAG-----CTGCAGCAGAACACCGGGCAGGAGCCTGGCGCGGCCAGTGTGGCCACACTAAACAGGGAGGAAGATGCAATGG------CAGGGAGCAGCTGCCCTGCAGTGGGCTCAAGGGCAGTCAGGACCCACTGTTTACTCAGGATCAACCTAGTTTTCTCCAACTGGCTTTTCTACCTGGGCCTGCATGCGGGCAGCCCACTGATGCTGGAAGGGGGCTGGTCTGGACCTCACACTCTACACCTGGTTTCACCTTCTTAGGCAGGATCCCTGTAGACCAGGCCCAAGACAAACACCATTCTAAGTGGGCAGGGTAAAGGAAGAGC------CCGGGC--TGGTGCAGCCATCCATCAGGAACGGCCAAACTTCTCCCGATGAAACTGGGGAGATGGGAAAAGGCAGTGAGAGACTAGATCTCAGGGTGA-GCAGGCTCGGGGGGGAAGGAAAAGGCAGGACTGACCTTACGCATAGCAGCAACAGCATGGCCAAAGGTGGCCTTGACCTCCACACGGTCTCGGATCCAGCCTGGCAGCTTTGCCAGGATGGGTGGGCGGGCATATCGCTGGTCTAGGAGCACTATGCTGGCAAAATCCCTCTGGTGCCTGATGGCTCTGCCTGGATGGGAACAGAATTTGGGGCTCCTAGGTAAA-------------------ATCCTCTCCTGTGACTTCATTCTC-------------------CAACCACCCAT--CTGTACTCC----------CAACTATCCATCCTGACAGCCAGGAGCAGTCCCAGGCTTACCTATAGATTGGTTGACAGCCTTCATACACAGATTCTCCACCAAGGCCTTCCCTGGTGGGGGCTGGCCTGGGGTTCTGGGCTGGGAAGGGTAGAAAGGACCTATCAGAACTGTTCCTTACCTCCTGTCTAGTGTTCTAGCTCTCCCTGGGAGAAGAGCCTGCCAGGCTTTGGAGCAAGACCAGGCAGCTTCACAAGCCAGTGCCAGCAGCTGG------CACGATGTCATGGAGAAGGTCAAGAGGGGGACAGGAAACACC--AGCATGGCAAGGAAGTCACAGCTACAAGACCCTGCTATCTCAG------CCTAGGGAATACACCACACTTCCCCCCGGCC--CTCTCCTCAT-CCTCTGGAATCCTGGAGGTACTCACAAGGGTCTGATCCAAGTAGGTCATCTTCTCTTGTAGTTCTGGAGAGTTGATGTTGGGGTAGGGCATGCCCACCATCACTACACACCTAGGTGGAGATGCACGCCGATGGGCATGTGGCCTCACACTCACTGAGTCCTCACCCACATGCCACCGACTGCT--GCTCTACCTCTGCTGCCG--CTCTTGGCTATGCTCGGCAGCTCTACCCTCCGCATC-CCGTACCTACCACCTGGAAAGGATTTTTTCAGCTAAGAGACCCAGTCTAAGCCAATGAACATAGTCCTGATAAGGTTATGGTTTGCCCCATTTTCCATCTGCTCT-CAAAGGCCCAATCCAGAGTTGCTGAAACACTTCCCGCCTGGCTGCCTGATCCTGAGCAGC--CAGCCTGGGTGCAGACTCAGATGGCATCAGATTGCAGGT-GGGGCCCAGCTGCTGGAAGTGAGGAGTAGCCAGGTGTCATAGCCCCAGGAGAGAAGGAGAGGACCACTACTTACCGGCCTAGGTTGTCAGAGAAGTTAATCCCTTCACTCATCTTTCCTCCAACC
2057523 chrY 57214466 57215088 NW_007726181v1 1023265 1023919 + 29358
GGCCCATCCCACTCTAGGCATGGCTCCTCTCCACAGGAAAACTCCACTCCAGTGCTCAGCTTGCACCCTGGCACAGGCCAGCAGTTGCT---GGAAGTCAGACACCTGCAGATCAAGACCACAGCATCAAGACCCTGTGACCTCTCAAAGGCCTGGTGGAAAGGA--------------CACGG-----------GAAGTCTGGGCTAAGAGACAGCAAATACACATGAACAGAAAGAAGAGGTCAAAGAAAA--GGCTGACGGCAAGTTAACAAAAAGAAA--AATGGTGAATGATACCCGGTGCTGGCAATCTCGTTTAAACTACATGCAGGAACAGCAAAGGAAATCCGGCAAATTT-GCGcagtcattctcaacaccggccatgcagcaaaatcatcagtggaaatttaaaaaaatacacgtggccaggccccagcccaaatcact-aataagaatctccaggg-CTtcacctgttagactggcaaaaaatccaaaag--taaacactttgtggagaaacaggcactcctagacattgctggtgggatacagaacagtacaattctga------------tggtaatcagttaacaaattaaacatatttattttatacttttaaacccaggaatcccatatttaggagtctactgagaccaaacagc
GGCTCGCTCCGCCCGGGTCACA-CTCCTCACCGCAGGAGAACTCCACCAC-TCGCTCAGCCTCAGCCCCAGCGCACGCCAGCAGCTGCTCCCGGAAGTCAGACACCTGCAGA------CCACAATGGCAGGGCCCTGTGACCTCCCAGAGGCACAGGGGAGAAGAACCTCAGGCCTCGGCATGGAGGGCAAGACAGAAGTCTGGGCTGGAAGGCAGCAAGTACGTACAAACAGAAAAAAGAGCTAAAAAAAAAAAGGCTAACAACAAATTAACAATAATAAATAAATTGTTAATGATATCCAGTGTTGGCAGTTTCATTTAAGCTACTGGTAGAAACAGCAAAGGAAATCTGGCAAACTTGGCAcagtgattctcaaccctggctatgcatcaaaaccagcagtgggaatttaaaaaaatacACATGGCCCAGCCACAGTCCAAACTACTGAATAACAATCTCCAGGGttttcacctaccaaattggc---aaatccgaaagtttaaccactctgtggagaaaaaggcatttttaaacattgctggtgcaatacagaatagtacaactcttacataggggaatttgacaat-acttaacaaattaaatgga-----tttttactttttaactcaggaatctcatatctgggactccacccagaatacacagc
2057524 chrX 68 170 NW_007727164v1 23685 23787 - 4125
TCCAGACTACCAGACACAAGACATTACACATTGTAATGCATTAAATGCATAGTTTTAACAGTAATAATTTAAAAGAGATTTAGAATTTTATAATGTTTGGAAA
TCAAGGCCCCGGGCTACCTGACATTACCCTCATTAATGCATGAAATGCAGAATATTAACATGAGCAATTTAAGATGAACTTAAGATTCTGTAATGTTTAGAAA
|
$2 denotes the 2nd column
"chr19" means we are searching for only details associated with "chr19"
{c=3}c-->0 commands to output the next 2 lines of the searched pattern
awk '$2=="chr19"{c=3}c-->0' file > chr19_file
| Splitting a file into separate files based on a keyword on a particular column of each header line |
1,678,812,749,000 |
I am currently trying to create a short and portable way to check if my working git directory is dirty and return T/F accordingly.
My ultimate goal is to incorporate this into a Makefile and I have implemented it as such:
GIT_DIRTY := $(shell [[ -n $(git status -s) ]] && echo '\ dev')
My issue is that the [[ operator is bash only, and as a requirement this Makefile needs to be able to run with sh only, no more fully featured shells. My hunch is that there is a way to accomplish this using [ or test, but I am not sure how.
Thanks!
|
GIT_DIRTY := $(shell [ -n "$(git status -s)" ] && echo '\ dev')
should work - but it doesn't, even though the command works fine in sh. It seems something in the shell function of make does not like the command.
Here's a workaround using a simpler command to give to shell and using a conditional function in make itself to do the rest of the job:
GIT_STATUS := $(shell git status -s)
GIT_DIRTY := $(if ${GIT_STATUS},DIRTY,CLEAN)
all:
@echo ${GIT_DIRTY}
| Checking command nested in conditional with shell [duplicate] |
1,678,812,749,000 |
I have created a program in my personal computer and I want to upload all its files into an empty GitHub repository.
I cannot do so from GitHub GUI because some of these files are directories and currently GitHub GUI rejects uploading directories.
Could I use Git to upload these files, perhaps by a "pull request" to the empty GitHub repository (which I would later approve from GitHub GUI)?
I would prefer a solution without SSH.
Update
I was wrong, it is possible to upload directories to GitHub GUI directly;
It's just that the Windows 10 Home upload modal mislead me;
A GitHub support member used another upload modal (of Mac OS) which has a more intuitive upload modal instead the "Open" button in the Windows modal, but, after minimizing the modal I could drag the directory and upload it this way.
Marking the directory and click "Open" didn't cause uploading as it would with non directory files.
|
If you visit your empty repository on GitHub using a web browser, you’ll see instructions explaining how to populate it (see this empty repository for example):
Prepare a directory containing everything you want to upload, if you haven’t already done so.
Initialise a git repository inside it:
git init
Add all the files and directories, and commit this:
git add -A
git commit -m "Initial import"
Match the branch to that expected by GitHub:
git branch -M main
Add your GitHub repository as a “remote” (this assumes you’ve set up an SSH key):
git remote add origin [email protected]:roiko/foo.git
(replace the URL as appropriate).
Push your contents:
git push -u origin main
| Uploading files, some of which are directories, into an empty GitHub repository |
1,678,812,749,000 |
When I'm coding, I usually have 2 terminal tabs open in VSCode. The tab on the left is used for git commands. The tab on the right always has git log --all --graph --decorate --oneline showing me all the branches and commits.
I'm trying to make it so that the tab on the right reruns the git log command as soon as I checkout branches, checkout new branches, commit, push, pull...
I tried this:
# watchgit.sh
inotifywait -m .git/refs -m .git/HEAD |
while read dir action file; do
git log
done
but it doesn't refresh. I also don't mind if I get a few extra refreshes here and there.
Would appreciate some help.
Thanks!
|
Take look to the bottom right there is the (END) this comes from the pager used by git.
There --no-pager to avoid this issue
Then do while to react to each event around inotifywait:
while inotifywait .git/refs .git/HEAD ; do
git --no-pager log --decorate=short --pretty=oneline
done
| How to create a bash script that watches my local git repo and runs 'git log' every time I commit/checkout -b/push/status? |
1,678,812,749,000 |
I am trying to clone a repo from gitlab into Oracle VirtualBox VM (CentOS) hosted on Win 10 machine.
Following are the steps:
generate key via ssh-keygen -t rsa and copy the key from generated id_rsa.pub file into gitlab > preferences > ssh keys
Run the following git command to clone the repo - but it fails with error "Host key verification failed" - on close observation .ssh dir that contains the id_rsa files does not contain known_hosts file
$ git clone git@gitlab.<...>.git
Cloning into '<repo>'...
The authenticity of host 'gitlab.<...> (---.---.---.---)' can't be established.
ECDSA key fingerprint is SHA256:.......
Are you sure you want to continue connecting (yes/no/[fingerprint])? y
Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
$
Also - trying to delete any existing host file does not work
$ ssh-keygen -R <hostname>
do_known_hosts: hostkeys_foreach failed: No such file or directory
I am able to clone the same repo into Windows machine so there is no issue with repo's existence. Also, in other machines, cloning is successful.
Any leads on this would be much appreciated.
|
Ok so the issue was that in my PATH variable /usr/bin entry somehow preceded usr/bin/git - this was a duplicate entry along with the one at the end of the PATH variable - this caused the issue. Learnt another way of not causing a mistake.
| Unable to clone repo from gitlab into Oracle VirtualBox VM (CentOS) - host key verification failed |
1,678,812,749,000 |
I'm writing a tampermonkey script, using git and jsdelivr to store and send it to the users.
For the jsdelivr to work correctly, i need to change the commit hash in the url.
// @require https://cdn.jsdelivr.net/gh/tunisiano187@2020072501/WME-send-to-slack/WMESTSData.user.js
In this case the part to be replaced is 2020072501 (not currently a hash)
I have a variable containing the hash, but i need to find the sed -i command to make the change (the hash will be changed in the file)
i'm thinking to use sed -i for it, but it's not doing what i want.
I've tryied this (without var to start)
sed -i "s/187@(.*)\/WME-/187@newhash\/WME-/g" WME-send-to-slack.user.js
Do you have an idea of what's wrong?
here is an example of the hash : e7327fbef446fb70370bc123296ecef5cd71eb48
Thank you
|
sed "s/187@[[:xdigit:]]*\/WME-/187@newhash\/WME-/g"
If you need to use extended regular expressions, use sed -r.
| Help with regex with sed -i for a tampermonkey script |
1,593,423,671,000 |
I have the below path for our Bitbucket repositories
/bbshared_storage/archive/data/repositories
The directories inside go by numbers (each number represent repository):
1000, 1001,1002 and so on.
Inside each repository, I have the repository-config file, which contains the project name:
[bitbucket]
hierarchy = XXXXXX
project = {The value I need}
repository = XXX
I need to write a script that runs in a loop on all the repositories, with the git fsck command. In the end it must have a file that contains the repository name, with its fsck results: OK or error (I assume by using echo $? and asking if it's different from 0). Can you advise on a nice way to write it?
|
I wrote the below, although I guess there is a better way:
for /bbshared_storage/archive/data/repositories/*
do
cd /bbshared_storage/archive/data/repositories/"$i"
Rep=$(grep -E 'project|repo' repository-config | tr '\n' ' ')
git fsck
if [[ $? == 0 ]]
then
echo "$Rep Good">>/tmp/BB_list.log
else
echo "$Rep Bad">>/tmp/BB_list.log
fi
done
| Help with writing script file for bitbucket repositories File System ChecK |
1,593,423,671,000 |
{
"changed": false,
"cmd": "/bin/git clone --bare ssh:********@enterprise.acme.net:7999/acme/acme-whm.git /usr/local/acme/.git",
"msg": "Warning: Permanently added [enterprise.acme.net]:7999,[10.0.37.37]:7999 (RSA) to the list of known hosts.\r\nPermission denied (publickey).\r\nfatal: Could not read from remote repository.\n\nPlease make sure you have the correct access rights\nand the repository exists.",
"rc": 128,
"stderr": "Warning: Permanently added [enterprise.acme.net]:7999,[10.0.37.37]:7999 (RSA) to the list of known hosts.\r\nPermission denied (publickey).\r\nfatal: Could not read from remote repository.\n\nPlease make sure you have the correct access rights\nand the repository exists.\n",
"stderr_lines": [
"Warning: Permanently added [enterprise.acme.net]:7999,[10.0.37.37]:7999 (RSA) to the list of known hosts.",
"Permission denied (publickey).",
"fatal: Could not read from remote repository.",
"",
"Please make sure you have the correct access rights",
"and the repository exists."
],
"stdout": "Cloning into bare repository /usr/local/acme/.git...\n",
"stdout_lines": [
"Cloning into bare repository /usr/local/acme/.git..."
]
}
Why would I be getting this problem if I have
accept_hostkey: True
In my play?
- name: Clone Git
environment:
TMPDIR: "{{ acme_root }}"
git:
bare: yes
track_submodules: yes
accept_hostkey: yes
repo: "{{ acme_repo_upstream }}"
dest: "{{ acme_root }}/.git"
|
Regardless of whether or not you can connect to Ansible and what your options are with Git if you see the following message,
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the ECDSA key sent by the remote host is
SHA256:J6ErF8jeZVKGsg0db5u2hiNeQbH4pdGzPcbpGXZhOm8.
Please contact your system administrator.
Add correct host key in /home/ecarroll/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /home/ecarroll/.ssh/known_hosts:50
remove with:
ssh-keygen -f "/home/ecarroll/.ssh/known_hosts" -R "10.1.38.15"
ECDSA host key for 10.1.38.15 has changed and you have requested strict checking.
Host key verification failed.
Then your agent will not forward. If you run ssh-add -l you'll see,
Could not open a connection to your authentication agent.
And, you'll have to run
ssh-keygen -f "/home/ecarroll/.ssh/known_hosts" -R "10.1.38.15"
And then reconnect.
| Ansible git Permission denied (publickey) |
1,593,423,671,000 |
Here’s a Yet Another Question about the clash between ssh and gnome-keyring-daemon, since after spending hours and hours on the Internet I finally gave up.
Environment
OS: openSUSE 15.0
DE: XFCE
gnome-keyring-daemon version: 3.20.1
seahorse version: 3.20.0
git version: 2.16.4
ssh version: OpenSSH_7.6p1, OpenSSL 1.1.0i-fips 14 Aug 2018
Situation
Trying to git pull a repo leads to a message
sign_and_send_pubkey: signing failed: agent refused operation
, even though for years I was getting a neat GUI prompt which remembered the typed password throughout the current session. (AFAIU, this prompt was shown by Seahorse?).
After doing a killall gnome-keyring-daemon, successive attempts to do a git pull lead to a terminal prompt
Enter passphrase for key '/home/user/.ssh/id_rsa':
which does not store the password anywhere (AFAIU, this means that ssh-agent is not working?).
The same effect can be achieved by adding SSH_AUTH_SOCK=0 in front of git pull.
What I want
Doing a git pull caches my SSH password over the course of my current login session (like it was before). Neat GUI prompt is optional.
Ed25519 keys are supported. (Apparently GNOME Keyring has (had?) some problems with them).
What I tried
Disabling “SSH Key Agent” in XFCE settings → Startup Applications
Copying /etc/xdg/autostart/gnome-keyring-ssh.desktop to ~/.config/autostart and then appending the line Hidden=true to the copied file
Neither of the above prevented gnome-keyring-daemon from starting up on boot, since I still can see it in ps.
Creating ~/.pam_environment then adding GSM_SKIP_SSH_AGENT_WORKAROUND DEFAULT=1 there
Reverting back to RSA
Playing with ssh-add
Installing git-credential-libsecret then doing git config --global credential.helper /usr/lib/git/git-credential-libsecret
Toying with the thought of obliterating the gnome-keyring package altogether, which was abandoned because apparently several important packages depend on it
|
I think I finally found a nearly perfect solution: FunToo Keychain.
It's a deliciously simple console application which you just add to your ~/.bashrc, and then every time you open a terminal it automatically unlocks your SSH keys.
Basically the only difference between it and the gnome-keyring+Seahorse combo I was using is that it asks for your password as soon as you open a terminal for the first time during a session (as opposed to the first time you try to use your SSH key), which can be annoying if you rarely use SSH. It's not my case though, so I'm content.
| Yet another `sign_and_send_pubkey: signing failed: agent refused operation` |
1,593,423,671,000 |
I want to delete a particular branch in a repo with help of api using shell script
i have gone through official document https://docs.atlassian.com/bitbucket-server/rest/4.14.4/bitbucket-branch-rest.html which has details of api to delete all the branches of a repo but not specific branch in a repo
|
Got the answer , below is the api
{bitbucket_url}/rest/branch-utils/1.0/projects/{project_name}/repos/{repo_name}/branches -H "content-type: application/json" -d "{"name": "{branch_name}" ,"dryRun": false}"
| Deleting a particular branch of a in bitbucket repo using API (Shell script) |
1,593,423,671,000 |
I have a dynamic menu on dialog (the items are provided from an array) but the menu is not displaying the selected option
gp_options=()
for i in `find ~ -type d -name .git`; do
gp_options+=("" "$i")
done
gp_dialog=(dialog --stdout --extra-button --help-button \
--ok-label 'Access repository' \
--extra-label 'Create repository' \
--cancel-label 'Remove repository'
--help-label 'Cancel' \
--backtitle "Welcome to Git Bash `whoami`!" \
--title ' Manage repositories ' \
--menu 'Manage repositories' \
0 0 0 \
"${gp_options[@]}")
dialog --stdout --msgbox "$manage_repositories" 0 0
|
After hours of research, i finally found a answer:
repositorios=() ; i=0
while read -r line; do
let i=$i+1
repositorios+=($i "$line")
done < <( find ~ -type d -name .git )
gerenciar_repositorios=$(dialog --stdout --extra-button --help-button \
--ok-label "Acessar repositório" \
--extra-label 'Criar repositório' \
--cancel-label 'Remover repositório' \
--help-label 'Cancelar' \
--backtitle "Bem vindo ao Git Bash `whoami`!" \
--title ' Gerenciar repositórios ' \
--menu 'Gerenciar repositórios' 0 0 0 \
${repositorios[@]})
| can't output dialog value on bash |
1,593,423,671,000 |
After the upgrade to Fedora 27, I can't clone urls using https anymore, ssh works fine. The error is:
fatal: unable to access 'https://repo-url': SSL certificate problem: unable to get local issuer certificate
I didn't change anything and my /etc/pki directory is almost the same like the one of a friend who's still using F26.
I already tried:
reinstalling git (2.14.3-2.fc27)
reinstalling ca-certificates (2017.2.16-4.fc27)
setting the git option sslCaInfo to /etc/pki/tls/cert.pem
Any other ideas?
|
Here are my ideas (I'd suggest to try again after each step so you can stop when your problem is fixed):
Reinstall git-core (because it contains the relevant component: /usr/libexec/git-core/git-remote-https. I used strace and dnf provides to find that out)
Reinstall ca-certificates (Should be Version 2017.2.16)
Go to /etc/pki/ca-trust/extracted/pem and rename the file tls-ca-bundle.pem. (Warning: This will temporarily break most of your SSL stuff, do remember to rename it back to the original name later.) Does the output of your git clone change? For me it reads:
fatal: unable to access 'https://github.com/some_git': error setting certificate verify locations:
CAfile: /etc/pki/tls/certs/ca-bundle.crt
CApath: none
Find all packages which git depends on with sudo dnf repoquery --requires --resolve git (this may take some time) and reinstall them.
| Can't clone https urls with git |
1,593,423,671,000 |
I am following a tutorial on installing git on a shared host and need some clarification if possible.
I have access to the GCC
jpols@MrComputer ~
$ ssh nookdig1@***.***.**.*'gcc --version
gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-18)
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.'
and can edit the bashrc file:
jpols@MrComputer ~
$ vi .bashrc
However I dont really understand how to read if the path has been added correctly:
Update your $PATH None of this will work if you don’t update the $PATH
environment variable. In most cases, this is set in .bashrc. Using
.bashrc instead of .bash_profile updates $PATH for interactive and
non-interactive sessions–which is necessary for remote Git commands.
Edit .bashrc and add the following line:
export PATH=$HOME/bin:$PATH
I added the above to the file and saved but it goes on to say
Be sure ‘~/bin’ is at the beginning since $PATH is searched from left
to right;
But ~/bin is different to the given path. Could someone please explain what this means?
After adding the Path as specified the output is:
jpols@MrComputer ~
$ source ~/.bashrc
jpols@MrComputer ~
$ echo $PATH
/home/jpols/bin:/usr/local/bin:/usr/bin:/cygdrive/c/Python27:/cygdrive/c/Python27/Scripts:/cygdrive/c/WINDOWS/system32:/cygdrive/c/WINDOWS:/cygdrive/c/WINDOWS/System32/Wbem:/cygdrive/c/WINDOWS/System32/WindowsPowerShell/v1.0:/cygdrive/c/Program Files/nodejs:/cygdrive/c/Program Files/Git/cmd:GYP_MSVS_VERSION=2015:/cygdrive/c/WINDOWS/system32/config/systemprofile/.dnx/bin:/cygdrive/c/Program Files/Microsoft DNX/Dnvm:/cygdrive/c/Program Files/Microsoft SQL Server/130/Tools/Binn:/cygdrive/c/HashiCorp/Vagrant/bin:/cygdrive/c/MAMP/bin/php/php7.0.13:/cygdrive/c/ProgramData/ComposerSetup/bin:/cygdrive/c/Program Files (x86)/Yarn/bin:/cygdrive/c/Program Files/PuTTY:/cygdrive/c/Program Files (x86)/Brackets/command:/cygdrive/c/Program Files (x86)/Calibre2:/cygdrive/c/Ruby22-x64/bin:/cygdrive/c/Users/jpols/AppData/Local/Microsoft/WindowsApps:/cygdrive/c/Users/jpols/AppData/Roaming/npm:/cygdrive/c/Users/jpols/AppData/Roaming/Composer/vendor/bin:/cygdrive/c/Users/jpols/AppData/Local/Yarn/bin:/cygdrive/c/Program Files (x86)/Nmap
Just comparing the first part:
Tutorial: /home/joe/bin:/usr/local/bin:/bin:/usr/bin
Mine: /home/jpols/bin:/usr/local/bin:/usr/bin:/
They are different so before I go on I am hoping someone can explain what I am trying to achieve and how to do it correctly. Thanks.
|
The '~' character is used to indicate the current user's home directory on UNIX systems. Because the username on your computer is different from the one on the machine used in the tutorial you referred to, different directory paths have been appended to the PATH variable. By using '~' one does not have to manually enter one's username for referring to the user home directory, which allowed the creator of the tutorial to create code which makes the PATH variable look into both of your home directories, even though both of your systems have different paths to your home directories. (e.g. /home/joe/bin and /home/jpols/bin are different directories, but ~/bin can be used to refer to both, as the '~' will be expanded to the correct path by the system)
| Clarification on updating path in bashrc |
1,593,423,671,000 |
I'm trying to write a program that will get an object from github, without cloning the entire repo. The last line does not work, giving me
a Syntax error: "(" unexpected. It is supposed to remove all files / directories except for that.
#!/bin/sh
object=$2 #sets item not to remove as second argument
address=$1 #sets github address (github.com/user/repo)
git clone $1 #clones it
location="${address##*/}" #gets part after last backslash
cd $location #cd's into it
#Syntax error: "(" unexpected
rm -rf !("$object")
|
The extglob syntax for bash is not enabled by default, and that's what will give you the !(...) syntax. You'll have to turn it on if you want, by first changing your shebang to use bash
#! /bin/bash
then by turning on extglob by adding
shopt -s extglob
somewhere before that line
| Remove all objects in repo but specified object |
1,593,423,671,000 |
While cloning git repository I am getting the following error
Failed to connect to github.com port 443:Network is ureachable while I am able to clone on my windows machine
Edited-
git clone https://github.com/Rishav09/Mywebsite.git
I am getting the following error
Cloning into 'Mywebsite'...
fatal: unable to access 'https://github.com/Rishav09/Mywebsite.git/':
Failed to connect to github.com port 443: Network is unreachable
|
Is there a firewall/proxy in place restriciting access?
Can you clone via SSH (note: you'll need a GitHub account and need to add your public SSH key to your profile to be able to SSH in).
git clone ssh://[email protected]/Rishav09/Mywebsite.git
| Unable to clone git repository on ubuntu [closed] |
1,593,423,671,000 |
I'm currently trying, for fun, to build a package management system (similar to apt / yum / zypper, etc...) using the git revision system, and I' searching for a way to know what is the latest stable version of the current branch.
Example : the Linux kernel
I would like to know, from the 3.18 branch, what is the latest tag (currently "3.18.9"), and, if possible, the commit identification code (currently "d1034e83796a0433194f67c2a8c4abf0f6138b01").
How can I do it without having to downloading all the repository?
|
There might be a simpler variant, but the following will get you the commit SHA-1 of the last commit to the master branch:
git show -s origin/master
(assuming your remote is called origin in your local repository).
If you only want the commit,
git show -s origin/master | awk 'NR == 1 { print $2 }'
To make sure you're getting the latest information, you should git fetch beforehand. Referring to origin/master means this works regardless of the state of your local master, so you don't need to git pull.
You can't use git locally without cloning the repository you're interested in, but you can limit the amount of data copied by using --depth and --branch options to git clone; for example
git clone --branch linux-3.18.y --depth 5 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
to clone the last five history entries in the linux-3.18.y branch of the stable kernel tree. This is called a shallow clone and has a number of limitations; see the git clone documentation for details.
| get the tag of a git branch |
1,593,423,671,000 |
I'm trying to deploy my sites on my company's semi-managed vps server using this tutorial: https://www.digitalocean.com/community/tutorials/how-to-set-up-automatic-deployment-with-git-with-a-vps
It works on my own Digital Ocean servers without change, but things are set up differently on my company server.
The public_html folders need to be owned by the whm account user, or you get 500 errors. But the git user needs to own the public_html folder for this method to work. So I'm modifying the post-receive script to include commands to change the owners, but it doesn't seem to work. What am I doing wrong?
#!/bin/sh
# REPLACE *** WITH ACCOUNT USERNAME
# Change owner of html folder to git
find /home/***/public_html -user root -exec chown -R git:git {} + 2>>logfile
echo "Changed owner to git."
# Update html folder with git push contents
git --work-tree=/home/***/public_html --git-dir=/home/***/repo/live.git checkout -f
echo "Updated public html."
# Restore ownership of directories
find /home/***/public_html -user root -exec chown -R ***:*** {} + 2>>logfile
find /home/***/public_html -user root -exec chown ***:nobody {} + 2>>logfile
echo "Changed owners back."
|
I would do away with find; since you know where the directory is, you should just deal with it directly. The find command introduces a new condition that could fail.
In either case, you are not terminating the find command, which could be a problem.
This might work better:
#!/bin/sh
# REPLACE foo WITH ACCOUNT USERNAME
# Change owner of html folder to git
chown -R git:git /home/foo/public_html || echo "$date I failed." >> /tmp/foo.log
echo "Changed owner to git."
# Update html folder with git push contents
git --work-tree=/home/foo/public_html --git-dir=/home/foo/repo/live.git checkout -f || echo "$date Git failed." >> /tmp/foo.log
echo "Updated public html."
# Restore ownership of directories
chown -R foo:bar /home/foo/public_html
chown foo:nobody /home/foo/public_html
echo "Changed owners back."
| I'm trying to deploy with git to a semi-managed vps, need to write a script to change owners |
1,598,865,843,000 |
I could copy the archive to the server from local using:
scp forum.tar.gz root@servername:/root/
However, when I tried to send from server to the local
[root@iz2ze9wve43n2nyuvmsfx5z ~]# scp draft.md root@localhot:/
ssh: Could not resolve hostname localhot: Name or service not known
lost connection
How could I get this job done,
Should I must depend the github to commit and pull?
|
ssh: Could not resolve hostname localhot: Name or service not known
First, you've misspelled localhost.
Second, in this command, localhost means the host the scp command is currently running on.
If you use
scp forum.tar.gz root@servername:/root/
to copy a file from the current directory on the local system to /root/forum.tar.gz on the server, then
scp root@servername:/root/draft.md .
will copy the file /root/draft.md from the server to the current directory (.) on the local system.
Since /root is presumably the home directory of the root user, you can even shorten the second command to:
scp root@servername:draft.md .
When specifying a source or destination name for scp, a colon (:) in the name means that you're specifying a pathname on some remote host. If there is no slash (/) after the colon, the remote pathname is relative to the remote user's home directory; if there is a slash after the colon, it will be an absolute path.
| Scp remote files to the local [closed] |
1,598,865,843,000 |
Git has its own versions of commands such as mv and rm that we really ought to use when doing these operations inside repositories.
However, I'm sure I'm not the only person who often forgets to do this.
Is there any way to automatically use these tools when operating within a git repository?
I'm interested in answers for any of bash, zsh or fish.
|
I suggest you have some myrm / mymv script that git rev-parse in order to detect if you are inside the repo and act accordingly. Something like :
ingitr="$(git rev-parse --is-inside-work-tree 2>/dev/null)"
if [ "$ingitr" ]
then
git rm $1 ( git mv $1 $2 )
else
rm $1 ( mv $1 $2 )
fi
Of course this is for a starting point. It should certainly be enhanced in order to take care of options.
However I read from comments that… you should not want that. (I'll remove this answer under pressure… ;-)
| Use Git Version of mv/rm etc When in Repository |
1,598,865,843,000 |
I want to create a Jenkins pipeline which runs GIT clone sanity every 5 minutes. how can I catch error/issue if the GIT clone command is not working/fails or passed?
|
The general approach is
if command; then
# Every went OK
else
# Something failed
fi
and it works for git:
if git clone ...; then
# The repo was cloned correctly
else
# Something failed
fi
The first branch is only taken if the git clone command exits with a status of 0, indicating success; any other exit status is considered failure, and causes the second branch to be taken.
| Create sanity for GIT clone |
1,598,865,843,000 |
I did this (was trying to set an 'self' alias with -v):
git() { if [[ $1 == "commit" ]]; then command git commit -v; else command git "$@"; fi; }
git() { if [[ $1 == "commit" ]]; then command git commit -v; else command git "$@"; fi; }
git() { git commit }; )
git() { git commit; }
git() { git (); }
git() { git(); }
git() { git() }
and now all git commmands hang - no error but no return prompt.
I've uninstalled and installed git but it hasn't helped.
How can I reset git command back to the default?
I've tried mv .gitconfig .gitconfig_old but it didn't help.
|
You sound really confused.
All those function definitions you ran were in the shell. If you ran them directly from the command line, then they only affect the current running shell environment. So if you had just closed the terminal and started a new one, the definitions would have been lost, and everything would be back to normal. Or you could have unset the definition with unset -f, as described in the comment.
This is why re-installing git has no bearing on your problem.
Renaming your .gitconfig won't make any difference either. You didn't make the changes in your .gitconfig, so why would it?
If you had followed the advice in your previous question, and set up an alias using git's aliasing method instead, then moving your .gitconfig would indeed have had an effect, and would have effectively removed your alias (along with all the rest of your configuration).
Incidently, all this confusion with the base command being overridden is the main reason git doesn't allow this type of name remapping under its own aliasing system. To quote the git-config manpage:
"To avoid confusion and troubles with script usage, aliases that hide
existing git commands are ignored."
| my git is messed up for all commands, how can I fix it? |
1,598,865,843,000 |
Usually the way I do renames to make sense for myself is -
$ git clone <remote URL.git>
$ mv remotedir nameIwant
I was wondering if there is a better way to do it.
The reason is sometimes I wanna try some of the forks and wanna keep the main repo. as pristine and the forks also renamed from where they came from. I do know that in ~/.git/config of the repo you can get the remote path but its easier to remember this way.
Is there a better way to do that ?
I did searches on the web but couldn't find anything which helped me.
|
Try specifying the desired name of the target directory after your command, e.g.,
git clone <remote URL.git> nameIwant
From man git-clone:
<directory>
The name of a new directory to clone into. The "humanish" part of
the source repository is used if no directory is explicitly given
(repo for /path/to/repo.git and foo for host.xz:foo/.git). Cloning
into an existing directory is only allowed if the directory is
empty.
| how to rename a remote repo name so that it makes sense to you while git cloning [duplicate] |
1,598,865,843,000 |
Question in the title, but let me detail more. Excluding the ID/Password method on git CLI, we generate a SSH key and add the public key to the remote server. Why don't we have SSH-less public-key cryptography methods? We are not even connecting to remote a machine's terminal, we don't even need to connect a remote machine's terminal (do we?), so why is it named as SSH key? Is it just about naming convention, or something else? What is the history behind that?
|
As one StackOverflow answer says (mentioned in a comment), early in Git's history the ssh protocol had the benefits of supporting both read and write access to the backend repo, as well as cryptographically strong authentication and encryption.
Another benefit of ssh is it allows managing/replacing the keys independently of your deploy software. I.e., your deploy scripts don't have to know how to read the auth token from somewhere and and deliver it to the server.
There certainly are other protocols with comparable functionality, but these are among the reasons that git+ssh became so widely used over the past 10+ years.
| Why git authentications works through SSH keys? |
1,598,865,843,000 |
For learning the inner-workings of Git, I wanted to compute commit hashes manually as described by this SO answer.
However, while printf works (see below), I get strange behaviour with echo, which outputs spaces before the command substitution.
Why does echo put embed those spaces in the output?
Incorrect (echo):
$ (echo -ne "commit $(git cat-file commit cc540cb | wc -c)\0"; git cat-file commit cc540cb) | hexdump -Cv
00000000 63 6f 6d 6d 69 74 20 20 20 20 20 20 32 31 38 00 |commit 218.|
00000010 74 72 65 65 20 34 35 64 38 62 30 35 38 32 65 32 |tree 45d8b0582e2|
00000020 34 62 39 61 66 66 38 62 34 64 34 65 35 66 33 31 |4b9aff8b4d4e5f31|
00000030 65 35 38 64 62 38 37 38 61 33 64 32 35 0a 70 61 |e58db878a3d25.pa|
00000040 72 65 6e 74 20 64 64 31 37 31 64 61 35 62 61 64 |rent dd171da5bad|
00000050 31 34 62 36 30 37 36 65 64 64 36 30 66 35 38 33 |14b6076edd60f583|
00000060 33 63 39 33 63 65 38 33 61 36 66 64 61 0a 61 75 |3c93ce83a6fda.au|
00000070 74 68 6f 72 20 6e 6c 79 6b 6b 65 69 20 3c 6e 6c |thor nlykkei <nl|
00000080 79 6b 6b 65 69 40 67 6d 61 69 6c 2e 63 6f 6d 3e |[email protected]>|
00000090 20 31 35 38 36 37 30 33 39 31 39 20 2b 30 32 30 | 1586703919 +020|
000000a0 30 0a 63 6f 6d 6d 69 74 74 65 72 20 6e 6c 79 6b |0.committer nlyk|
000000b0 6b 65 69 20 3c 6e 6c 79 6b 6b 65 69 40 67 6d 61 |kei <nlykkei@gma|
000000c0 69 6c 2e 63 6f 6d 3e 20 31 35 38 36 37 30 37 34 |il.com> 15867074|
000000d0 35 38 20 2b 30 32 30 30 0a 0a 41 77 65 73 6f 6d |58 +0200..Awesom|
000000e0 65 20 72 65 62 61 73 65 21 0a |e rebase!.|
000000ea
Correct (printf):
$ (printf "commit %s\0" $(git cat-file commit cc540cb | wc -c); git cat-file commit cc540cb) | hexdump -Cv
00000000 63 6f 6d 6d 69 74 20 32 31 38 00 74 72 65 65 20 |commit 218.tree |
00000010 34 35 64 38 62 30 35 38 32 65 32 34 62 39 61 66 |45d8b0582e24b9af|
00000020 66 38 62 34 64 34 65 35 66 33 31 65 35 38 64 62 |f8b4d4e5f31e58db|
00000030 38 37 38 61 33 64 32 35 0a 70 61 72 65 6e 74 20 |878a3d25.parent |
00000040 64 64 31 37 31 64 61 35 62 61 64 31 34 62 36 30 |dd171da5bad14b60|
00000050 37 36 65 64 64 36 30 66 35 38 33 33 63 39 33 63 |76edd60f5833c93c|
00000060 65 38 33 61 36 66 64 61 0a 61 75 74 68 6f 72 20 |e83a6fda.author |
00000070 6e 6c 79 6b 6b 65 69 20 3c 6e 6c 79 6b 6b 65 69 |nlykkei <nlykkei|
00000080 40 67 6d 61 69 6c 2e 63 6f 6d 3e 20 31 35 38 36 |@gmail.com> 1586|
00000090 37 30 33 39 31 39 20 2b 30 32 30 30 0a 63 6f 6d |703919 +0200.com|
000000a0 6d 69 74 74 65 72 20 6e 6c 79 6b 6b 65 69 20 3c |mitter nlykkei <|
000000b0 6e 6c 79 6b 6b 65 69 40 67 6d 61 69 6c 2e 63 6f |[email protected]|
000000c0 6d 3e 20 31 35 38 36 37 30 37 34 35 38 20 2b 30 |m> 1586707458 +0|
000000d0 32 30 30 0a 0a 41 77 65 73 6f 6d 65 20 72 65 62 |200..Awesome reb|
000000e0 61 73 65 21 0a |ase!.|
000000e5
|
wc -c outputs spaces before the number:
$ wc -c <file
6
In your first command, the string commit and the output of wc -c is kept within o double quoted string.
In your second command, the output of wc -c is use unquoted.
In an unquoted context, the shell would split the output on the characters in $IFS, which includes a space, before using the resulting words. (It would also do filename globbing on the words, but that does not matter here).
You would get the same output with your second command if you quoted the command substitution.
Although you think that the second command, with printf, is "correct", not quoting a command substitution is generally a bad idea, due to the splitting and globbing that the shell does.
I would suggest quoting the command substitution (because that's always a good practice), and instead explicitly delete the spaces from the output of wc -c:
(printf "commit %s\0" "$(git cat-file commit cc540cb | wc -c | tr -d ' ')"; git cat-file commit cc540cb) | hexdump -Cv
| Why does `echo -ne "commit $(git cat-file commit cc540cb | wc -c)\0"` outputs spaces before command substitution? |
1,598,865,843,000 |
I have a git server i have stood up. It is a basic one with all the remote repositories stored under
/mygit/repo/
I can push and pull and all the other git stuff using this ssh syntax
ssh://git@myserver/mygit/repo/proj.git
However due to circumstances i need to be able to do the same using this ssh syntax
ssh://git@myserver:2200/proj.git
Now this where i am getting stuck, i have tried using apache to act as a redirect proxy to expand / into /mygit/repo using this in my .conf under conf.d
Listen 2200
<VirtualHost *:2200>
RedirectMatch "^/$" "/mygit/repo/"
DocumentRoot "/mygit/repo/"
</VirtualHost>
I tried using AllowCONNECT 22 to try and port forward port 2200 to 22 on the git server while doing an expand of the path to file.
|
Alrighty i managed to work out the answer. Everything needs to be done as root for the chroot jailed git repo to work.
So the first thing to do is to setup a chroot jail directory
/git/server/repos
This handy guide shows how the process is done https://www.tecmint.com/restrict-ssh-user-to-directory-using-chrooted-jail/
Once you have a chrooted jail for the git user you configure the sshd_config and add
Port 2200
Restart the sshd service. Then you need to add a usr directory followed by bin to the chroot jail and move the git commands.
mkdir -p usr/bin
cp -v /usr/bin/git* /usr/bin/
There are library files needed for the git commands so running ldd on the command in the bin directory will give you the name of the lib file.
ldd /usr/bin/git
The lib file i had and copied was
cp -v /lib64/libz.so.1/lib64/
Now you create your git repo as per normal but it must be as root as everything else and then you
chmod -R 777 mygitrepo.git
Now you chrooted git user can push and pull from the repo using the git commands under syntax
ssh://git@myserver:2200/mygitrepo.git
Rather than the absolute path if git wasn't chroot jailed
ssh://git@myserver:2200/git/server/repos/mygitrepo.git
| Git Server Binding Directory To Port |
1,598,865,843,000 |
Terminals like Terminator or Guake terminal are not able to parse prompt profiles for git which is set in .bashrc file. PS1 variable is not set for terminals which use xterm as base which guake and terminator terminals use.
So if custom functions are used for instance for displaying custom path if current directory is GIT directory then those variables or functions will not work.
Eg: $parse_git_branch
|
I figured out the solution, it was with .bashrc file in my home directory.
If we Open this file in text editor, here we will find a line where it's checking if the current terminal is xterm or not and setting some value to it:
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
;;
*)
;;
esac
So just comment given PS1 using # and then simply replace PS1 with this value:
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
# If this is an xterm set the title to user@host:dir
# old value:PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
case "$TERM" in
xterm*|rxvt*)
PS1="${debian_chroot:+($debian_chroot)}\[\033[1;34m\]\H:\[\033[1;35m\]\[\033[1;35m\]\w\[\033[1;92m\]\$(parse_git_branch)\[\033[0m\]$ "
;;
*)
;;
esac
| Terminals like Terminator or Guake terminal are not able to parse prompt profiles for git which is set in .bashrc file |
1,598,865,843,000 |
Easy question right? Just bare with me here..
I usually use Git to work with files on my local machine. I like this method because I can later check the files out on the shared drive for other non-git users to use. It is great because I can delete files (clean up) in my local directory and that cleans up remotely. I can leave all the extra files in the remote directory alone. This behaviour is why I do not simply rsync...
The only issue I'm having is in dealing with open files. Git stops the pull or reset when I encounter I locked file I need to change. Is this really a show-stopper? I may need to get a files out very quick and find it counter-productive to hunt down an unrelated open file blocking the process.
Can you help improve this process?
BTW: It is good enough to only update a file if the timestamp has changed. But I only want to update files that changed so that the incremental backups are not adversely effected.
Apparently this is uncommon so I'm not promoting it. The benefits are good for me though. This gives me fast local access to local files independent of network failure and basically seamless publishing to the backup drive. I just need to check-in often and push to make sure changes are backed up. It plays nice with other non-git files and users on the shared drive. Rsync falls short only because of the 'clean-up.' I can't --delete clean up without removing other users files. It may sound minor to clean up manually, but it is really a deal killer as clean up is error prone and requires testing.
|
Not to say there isn't a solution to this (although I don't know what it is), but, vis. "surely this must be a common task" -- probably not, because you are using the tool for a purpose it was not intended for.
git is a version control system, not a filesystem sync daemon or something. People doing VCS stuff are not in a rush to update things on a server without making sure their update is ready (we hope), so they are unlikely to be be bothered that it fails because something has obviously been overlooked ("I encounter I locked file I need to change" -- so make the changes you need to make, then commit).
Put another way, most users of git would probably hope there isn't a solution to this -- it's a user friendly feature.
| Trying to improve a sync to a shared drive |
1,598,865,843,000 |
I've accidentally created two branches for my Git repository: main and master, which I now need to merge.
However, when using ls on the command line while checked into main branch, some files on my computer don't show up (files that don't exist in the main branch on GitHub). When I use git checkout master the files "reappear".
But they must always be on my hard drive, so why are they hidden from view when checked into this one branch?
|
Git is not "hiding" these files from you, it is just that these files are only on the "main" branch. If you want just one branch with all your files, you can merge these branches by typing git merge master while you're checked into main.
If you want to learn more about how git's branches work: https://git-scm.com/book/en/v2/Git-Branching-Branches-in-a-Nutshell
If you want to learn about the merge command in a lot more detail: https://git-scm.com/docs/git-merge
| Is Git hiding files on my computer? |
1,598,865,843,000 |
I am able to get the file difference using git diff command and I got it filtered like below:
-This folder contains common database scripts.
+This folder contains common database scripts.
+
+
+
+New Line added.
However I want to be able to get only the difference that is the line New Line added. how can I achieve that - note that here I want to delete a pair of line containing
'+This folder contains common database scripts.' and
'-This folder contains common database scripts.'
and also remove white spaces (three '+ ' lines)
|
Try This:
If +New Line added. is the last line of the output of git diff:
git diff | tail -1 | tr -d '\n'
If you want to get rid of +
git diff | tail -1 | sed -e 's/^+//' | tr -d '\n'
| Filter the below text using shell commands |
1,598,865,843,000 |
While trying to start apacheds.service I am getting error like apacheds is not loading properly
|
The package has not been installed correctly. You can try to fix the installation with:
sudo apt-get -f install apacheds
You also have the option to reinstall it:
sudo apt-get remove apacheds
sudo apt-get install apacheds
Or just reconfigure it:
sudo dpkg reconfigure apacheds
Depending on the result of these commands you may be able to figure out what's the issue, or if you're lucky, one of these will just fix it.
| Apacheds unable to start [closed] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.