date int64 1,220B 1,719B | question_description stringlengths 28 29.9k | accepted_answer stringlengths 12 26.4k | question_title stringlengths 14 159 |
|---|---|---|---|
1,331,066,898,000 |
I'm trying to do a git clone trough a bash script, but the first time that I run the script and the server is not known yet the script fails. I have something like this:
yes | git clone [email protected]:repo/repoo.git
The authenticity of host 'github.com (207.97.227.239)' can't be established.
RSA key fingerprint is... |
Add the following to your ~/.ssh/config file:
Host github.com
StrictHostKeyChecking no
Anything using the open-ssh client to establish a remote shell (with the git client does) should skip the key checks to github.com.
This is actually a bad idea since any form of skipping the checks (whether you automatically hi... | Answer yes in a bash script |
1,331,066,898,000 |
We all know that Linus Torvalds created Git because of issues with Bitkeeper. What is not known (at least to me) is, how were issues/tickets/bugs tracked up until then? I tried but didn't get anything interesting. The only discussion I was able to get on the subject was this one where Linus shared concerns with about ... |
In the beginning, if you had something to contribute (a patch or a bug report), you mailed it to Linus. This evolved into mailing it to the list (which was [email protected] before kernel.org was created).
There was no version control. From time to time, Linus put a tarball on the FTP server. This was the equivalent o... | How did the Linux Kernel project track bugs in the Early Days? |
1,331,066,898,000 |
Assume I have some issue that was fixed by a recent patch to the official Linux git repository. I have a work around, but I’d like to undo it when a release happens that contains my the fix. I know the exact git commit hash, e.g. f3a1ef9cee4812e2d08c855eb373f0d83433e34c.
What is the easiest way to answer the question:... |
In GitHub kernel repository, you can check all tags/kernel versions.
Example for dc0827c128c0ee5a58b822b99d662b59f4b8e970 provided by Jim Paris:
If three-dots are clicked, full list of tags/kernel versions can be seen.
| Given a git commit hash, how to find out which kernel release contains it? |
1,331,066,898,000 |
Most of my my aliases are of this form: alias p='pwd'
I want to alias git commit so that it does git commit -v
But trying to create an alias with a space gives an error:
$ alias 'git commit'='git commit -v'
-bash: alias: `git commit': invalid alias name
|
Not a direct answer to your question (since aliases can only be one word), but you should be using git-config instead:
git config --global alias.civ commit -v
This creates a git alias so that git civ runs git commit -v. Unfortunately, AFAIK there is no way to override existing git commands with aliases. However, yo... | How can I create an alias for a git [action] command (which includes spaces)? |
1,331,066,898,000 |
Is there a way to identify with a username and password to github.com servers for the purpose of adding an ssh key to the github user account? So far everything I've read suggests that a user's ssh key must be added via the web GUI. I'm looking for the method or process of adding a key via a command line interface or ... |
Update 2020
As stated in developer changes, Password authentication is going to be deprecated at:
November 13, 2020 at 16:00 UTC
Additionally, as @trysis asked in the comments, we need a solution for 2FA.
The new way is to use a personal access token:
For our specific example (adding a ssh key), we only need write pe... | command line method or programmatically add ssh key to github.com user account |
1,331,066,898,000 |
I have find command that display files in my project:
find . -type f -not -path './node_modules*' -a -not -path '*.git*' \
-a -not -path './coverage*' -a -not -path './bower_components*' \
-a -not -name '*~'
How can I filter the files so it don't show the ones that are in .gitignore?
I thought that I us... |
git provides git-check-ignore to check whether a file is excluded by .gitignore.
So you could use:
find . -type f -not -path './node_modules*' \
-a -not -path '*.git*' \
-a -not -path './coverage*' \
-a -not -path './bower_components*' \
-a -not -name '*~' ... | Find files that are not in .gitignore |
1,331,066,898,000 |
I don't subscribe to the linux-kernel mailing list, but I want to get a set of patches that were posted a few weeks ago and apply them to my kernel for testing. I'm very familiar with patching, building, etc. My question is, what's the best way to get a copy of this patch set? It's not applied to any Git repo that ... |
http://marc.info/ has a link for each message to get the raw body, and https://lkml.org/ has (in the sidebar) links to download any contained diffs.
There are also archives with NNTP access that may provide raw messages, though I haven't tried this.
| How do I get a linux kernel patch set from the mailing list? |
1,331,066,898,000 |
The other day I tried installing opencv-git from the AUR with makepkg on Arch Linux. Of course it pulls from the git repository as the name indicates. This pulls 1Gb. I am reading about making a shallow clone with git. When I look at the PKGBUILD file, using grep git PKGBUILD, I see:
pkgname="opencv-git"
makedepends=(... |
This can be done by using a custom dlagent. I do not really understand Arch packaging or how the dlagents work, so I only have a hack answer, but it gets the job done.
The idea is to modify the PKGBUILD to use a custom download agent. I modified the source
"${pkgname%-git}::git+http://github.com/Itseez/opencv.git"
in... | How to modify a PKGBUILD which uses git sources to pull only a shallow clone? |
1,331,066,898,000 |
So I have a git repository that I cloned from an upstream source on github. I made a few changes to it (that are uncommitted in the master branch). What I want to do is push my changes onto my github page as a new branch and have github still see it as a fork.
Is that possible? I'm fairly new to git and github. Did my... |
You can do it all from your existing repository (no need to clone the fork into a new (local) repository, create your branch, copy your commits/changes, etc.).
Get your commits ready to be published.
Refine any existing local commits (e.g. with git commit --amend and/or git rebase --interactive).
Commit any of your u... | Github adding a repository as a fork from an existing clone |
1,331,066,898,000 |
I'm syncing ~/.gitconfig and ~/.gitignore files in ubuntu and Mac by using dropbox and created symlink for it.
And excludesfile is declared like this.
[core]
editor = /usr/bin/vim
excludesfile = /Users/username/.gitignore
The problem is home directory differs by os, therefore I need multiple setting f... |
You can only have a single core.excludesfile; the last setting is the one that's used. However, you don't need multiple files: git supports ~ as an abbreviation for your home directory.
[core]
excludesfile = ~/.gitignore
In general, if you really needed to have multiple excludes files, the simplest solution would... | How to set multiple `core.excludesfile` in `.gitconfig`? |
1,331,066,898,000 |
I am thinking on a system, where /etc were tracked on a remote git repository. I am thinking on a git workflow, where every host machine where a different branch.
Every previous versions on every machine could be easily tracked, compared, merged.
If a /etc modification had to be committed on many machines, it could be... |
The program etckeeper does manage /etc in git, you just need to change the default vcs backend from bzr to git in /etc/etckeeper/etckeeper.conf.
It is installed by default in Ubuntu Linux, and handles the common cases of when to commit automatically.
It commits before installing packages in case there are uncomitted m... | Using git to manage /etc? |
1,331,066,898,000 |
git log -G<regex> -p is a wonderful tool to search a codebase's history for changes that match the specified pattern. However, it can be overwhelming to locate the relevant hunk in the diff/patch output in a sea of mostly irrelevant hunks.
It’s of course possible to search the output of git log for the original string... |
here https://stackoverflow.com/a/35434714/5305907 is described a way to do what you are looking for. effectively:
git diff -U1 | grepdiff 'console' --output-matching=hunk
It shows only the hunks that match with the given string "console".
| Display only relevant hunks of a diff/patch based on a regexp |
1,331,066,898,000 |
Git seems to support configuration values at three levels:
Per-system global settings (stored in /etc/git-core)
Per-user global settings (stored in ~/.gitconfig)
Per-repository local settings (stored in $REPO/.git/config)
These options cover most of the basis but I'm looking for a way to handle a fourth level. I hav... |
I have found no way to configure git at this fourth level. The only way seems to be per-command configuration value overrides using git -c key=value.
My current hacky solution is to define a shell function that serves as a wrapper for git. When called, it passes the arguments onto the system git command, but not befor... | Can git configuration be set across multiple repositories? |
1,331,066,898,000 |
I created ssh key. I use it to connect with git repositories. When creating the key, I noticed the prompt that said the password should be hard to guess. Therefore, I came up with 40+ characters-long password. Now, every time I do git clone, push or anything similar, I need to input the password(which takes some time,... |
You can do this using an SSH agent. Most desktop environments start one for you; you can add your key to it by running
ssh-add
If you need to start the agent, run
eval $(ssh-agent)
(this sets up a number of environment variables).
The -t option to ssh-agent will allow you to specify the timeout. See Configuring the ... | Remember password for ssh key for some time |
1,331,066,898,000 |
Git completion:
I'm having difficulty with git's filename autocompletions on my system. I'm using zsh (5.0.5) with git (1.9.3) on OS X (10.9.3). Both zsh and git have been installed via homebrew. (Full version output are at the bottom of the post.)
git's filename completion isn't inserting spaces like I expect. When I... |
This bug is mentioned on the mailing list.
The fix is to edit the file git-completion.zsh and remove the -Q option from compadd, in in __gitcomp_file.
--- i/contrib/completion/git-completion.zsh
+++ w/contrib/completion/git-completion.zsh
@@ -90,7 +90,7 @@ __gitcomp_file ()
local IFS=$'\n'
compset -P '*[=:]'
... | git completion with zsh: filenames with spaces aren't being escaped properly |
1,331,066,898,000 |
I'm trying to get watch to display colors from 'git status'.
I've tried running watch with the --color option, as suggested elsewhere here, but, still, watch --color 'git status' doesn't display colors.
|
When git status is run under watch, it is able to detect that its standard output is not a terminal, meaning it will not output colors if the color.status setting is set to auto. To force git status to always output colors (even under watch), set color.stats to always, e.g.
git config color.status always
to set the... | watch command not showing colors for 'git status' |
1,409,919,431,000 |
less itself isn't capable of doing syntax highlighting, according to this thread.
However, git diff nicely shows colored output in less, its default pager. When I redirect the output of git diff into a file, no color escape sequences are visible.
Does git diff know where it's being sent, and formats the output accor... |
Git uses isatty() to check whether stdout is a tty: this is used to see if a pager must be used (pager.c) as well as colors (color.c).
| Git pager is less, but what is causing the output coloring? |
1,409,919,431,000 |
Naive approach is find dir1 dir2 dir3 -type d -name .git | xargs -I {} dirname {}
, but it's too slow for me, because I have a lot deep folder structures inside git repositories (at least I think that this is the reason). I've read about that I can use prune to prevent find to recurse into directories once it found so... |
Ideally, you'd want to crawl directory trees for directories that contain a .git entry and stop searching further down those (assuming you don't have further git repos inside git repos).
The problem is that with standard find, doing this kind of check (that a directory contains a .git entry) involves spawning a proces... | How to find all git repositories within given folders (fast) |
1,409,919,431,000 |
I use etckeeper for changes in my configfiles (on Debian squeeze)
Since I also have an ircdeamon running, there are some files, that change every minute in the folder
/etc/hybserv/
I don't want to version control them anymore, so I added
hybserv/*
to the end of
/etc/.gitignore
but they are not ignored! They keep s... |
You need to delete (=unregister) them from git.
Use something like
cd /etc
git rm --cached hybserv/*
git commit -m "Remove hybserv/* files from git"
Note the --cached option. With it, the files are only removed from git and are not deleted from the disk.
| Excluding files in etckeeper with .gitignore doesn't work |
1,409,919,431,000 |
I am trying to get a bash array of all the unstaged modifications of files in a directory (using Git). The following code works to print out all the modified files in a directory:
git -C $dir/.. status --porcelain | grep "^.\w" | cut -c 4-
This prints
"Directory Name/File B.txt"
"File A.txt"
I tried using
arr1=($(g... |
TL;DR
In bash:
readarray -t arr2 < <(git … )
printf '%s\n' "${arr2[@]}"
There are two distinct problems on your question
Shell splitting.
When you did:
arr1=($(git … ))
the "command expansion" is unquoted, and so: it is subject to shell split and glob.
The exactly see what that shell splitting do, use printf:
$ pr... | Read lines into array, one element per line using bash |
1,409,919,431,000 |
I work with LaTeX and do versioning with Git. For bibliography management I use Mendeley.
The problem is that each time Mendeley synchronizes it's .bib exports,
they are in different order, what makes bibliography versioning much harder.
My idea is to sort BibTex entries in .bib file, each time before commit.
Could yo... |
How about bibsort?
NAME
bibsort - sort a BibTeX bibliography file
SYNOPSIS
bibsort [optional sort(1) switches] < infile >outfile
DESCRIPTION
bibsort filters a BibTeX bibliography, or bibliography frag-
ment, on its standard input, printing on standard output a
sorted bibliography.
It's a ... | How to sort (by whatever key) BibTex entries in `.bib` file? |
1,409,919,431,000 |
Normally diff and git diff show both the original and the modified line with - and + respectively. Is there any way, I can filter only to see the modified line? This would reduce the number of lines to read by a factor of 2 instantly.
I was assuming
git diff test.yml | grep '^+' | less -R
and
git diff test.yml | eg... |
You can use --word-diff to condense the + and - lines together with the changes highlighted using red/green text and stop using grep all together.
You can combine this with -U0 to remove all context around the diffs if you really want to condense it down further.
This approch is better than using grep as you don't l... | diff to show only the additions in a changed file |
1,409,919,431,000 |
Possible Duplicate:
What does “--” (double-dash) mean?
git diff [options] [<commit>] [--] [<path>…]
In here, how should I understand what [--] means? And when should I use it.
|
As always, you should read a command's manpage to find out how it interprets its arguments.
-- is commonly used to indicate the end of the command options. This is especially useful if you want to pass a filename or other argument that begins with -. It's also a good idea to use it before wildcards that might expand... | What does "--" mean in Linux/Unix command line? [duplicate] |
1,409,919,431,000 |
I get the following error when accessing Github over HTTPS:
error: server certificate verification failed.
CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none
This is because I don't have any certificates in /etc/ssl/certs/. I know how to fix this problem. I can install the package ca-certificates from Debian r... |
In order to access your Github you need to do it via ssh. So you need to add your ssh public key to github. After that you are able to access github via ssh i.e.:
git init [email protected]:yourname/yourrepo.git
See also: Github: generating ssh keys, WikiHow
[Edit #1]
without certificate checks:
GIT_SSL_NO_VERIFY=tru... | adding SSL certificate for Github only (not all certificates from ca-certificates package) |
1,409,919,431,000 |
I'm tweaking the pager of Git, but I've got some issues with it.
What I want is:
Always colored output
Scrolling by touchpad or mouse
Quit-if-one-screen
And my current configuration is:
$ git config --global core.pager
less -+F -+X -+S
This does everything except the last one.
But, if I remove -+F, there will be no... |
UPDATE
tl;dr Solution: upgrade to less 530
From http://www.greenwoodsoftware.com/less/news.530.html:
Don't output terminal init sequence if using -F and file fits on one screen.
So with this fix we don't even need to bother determining whether to use -X on our own, less -F just takes care of it.
PS. Some other less ... | How to use "less -F" without "-X", but still display output if only one page? |
1,409,919,431,000 |
I am attempting to install git on Debian 8.6 Jessie and have run into some dependency issues. What's odd is that I didn't have any issues the few times I recently installed Git in a VM while I was getting used to Linux.
apt-get install git
Results in:
The following packages have unmet dependencies:
git : Depends: l... |
You should edit your sources.list , by adding the following line:
deb http://ftp.ca.debian.org/debian/ jessie main contrib
Then upgrade your package and install git:
apt-get update && apt-get upgrade && apt-get dist-upgrade
apt-get -f install
apt-get install git
Edit
the following package git , liberror-perl and [rs... | Unmet dependencies while installing Git on Debian |
1,409,919,431,000 |
I have googling awhile, but can not find such information. Looks like git doesn't contain users and groups, only permissions. Am I right?
|
See the Content Limitations section of the git Wiki: git does not track file ownership, group membership, doesn't track most permission bits, ACLs, access and modification times, etc.
Git tracks contents, and doesn't care much about pretty much everything else.
| Does git contain information about used id / group id changes? |
1,409,919,431,000 |
I want to build a debian package with git build package.(gbp)
I passed all steps, and at least, when I entered gbp buildpackage, This error appeared.
what does it mean?
and what should I do?
gbp:error: upstream/1.5.13 is not a valid treeish
|
The current tag/branch you are in, is not a Debian source tree, it doesn't contain the debian/ directory in its root. This is evident because you are using a "upstream/" branch, a name utilized to upload the pristine source tree to git repositories. Try using the branch stable, testing or unstable, or any branch that ... | what does " gbp:error: upstream/1.5.13 is not a valid treeish" mean? |
1,409,919,431,000 |
Is there any linux distro that has a git based package manager/installer. I want something similar to FreeBSD Ports (which is CVS based, I think) or Mac OS X Homebrew (git based).
|
There's Exherbo, which uses multiple Git repositories to store its exheres (its term for build recipes similar to Gentoo's ebuilds or BSD's ports). It's still a pretty young distribution, though.
Update: Gentoo recently moved to Git for its package repository. However, I don't think it's set up yet to have normal us... | Git based package manager/installer for Linux |
1,409,919,431,000 |
Heres the closest I've gotten: I installed gitolite in the /Private folder using ecryptfs-utils (sudo apt-get install ecryptfs-utils adduser git ecryptfs-setup-private then the rest was configuring gitolite using a root install).
It worked just fine as long as someone was logged in as the user git using a password (s... |
You simply need to remove the file ~/.ecryptfs/auto-umount.
This file is a flag that pam_ecryptfs checks on logout. This file exists by default at setup, along with ~/.ecryptfs/auto-mount, such that your private directory is automatically mounted and unmounted at login/logout. But each can be removed independently t... | How do I encrypt git on my server? |
1,409,919,431,000 |
Every time I do git pull or git reset, git resets changes to permissions and ownership I made. See for yourself:
#!/usr/bin/env bash
rm -rf 1 2
mkdir 1
cd 1
git init
echo 1 > 1 && git add 1 && git ci -m 1
git clone . ../2
cd $_
chmod 0640 1
chgrp http 1
cd ../1
echo 12 > 1 && git ci -am 2
cd ../2
stat 1
git pull
s... |
This sounds like the user you're running has the default group set to yuri. You can confirm this like so:
$ id -a
uid=1000(saml) gid=1000(saml) groups=1000(saml),10(wheel),989(wireshark)
The UID of your account is this: uid=1000(saml) whereas the default group is git=1000(saml) and any secondary groups are thereafter... | Is there a way to prevent git from changing permissions and ownership on pull? |
1,409,919,431,000 |
My indention is to have a script that updates all git submodules according to which branch is given. If there's no such branch for a submodule, master is used.
This is what I have now:
#!/bin/bash -x
if [ -z $1 ]; then
echo "Branch name required."
exit
fi
function pbranch {
exists=`git show-ref refs/head... |
I resolved my issue by putting the function inside of the quotes as a callback:
#!/bin/bash
if [ -z $1 ]; then
echo "Branch name required."
exit
fi
git submodule foreach "
branch=$1;
exists=\$(git show-ref refs/heads/\$branch | cut -d ' ' -f1);
if [ -z \$exists ]; then
branch='master';
... | Use git submodule foreach with function |
1,409,919,431,000 |
I have some problems with git-lfs and I think that upgrading to the latest git can fix this problems. Current version of git in Debian is 2.1.4, current stable version on official site is 2.6.4. Can I only build from source or maybe can I add some external repository?
|
As of December 2015, Debian stretch/sid has git version 2.6.4. If you don't want to upgrade your entire distribution, you can look into apt pinning to bring in only git and any necessary dependencies from stretch/sid. However, many Debian folks will tell you this sort of thing is a bad idea, so building from source ... | How to install latest git on Debian 8? |
1,409,919,431,000 |
$ git commit
error: cannot run vim: No such file or directory
error: There was a problem with the editor 'vim'.
Please supply the message using either -m or -F option.
How can I overcome the error and define the editor?
|
The answer was:
sudo apt-get install vim
as it was a new machine and vim wasn't installed.
| git commit error - cannot run vim: No such file or directory |
1,409,919,431,000 |
I have 3 users A,B and C inside a group 'admin'. I have another user 'D' in whose home directory, there is a project folder. I have made D as the owner of that folder and assigned 'admin' as the group using chgrp. Group and owners have all the permissions, but still A,B or C are unable to access the folder. I have two... |
Some points that seem to be necessary (though I freely admit that I am not expert in these matters), and that were not covered in RobertL's otherwise admirably thorough answer.
Make sure that the other users have actually logged into group admin:
A$ newgrp admin
Since the users are already in the group, I think yo... | Can users in a group access a file that is in another user's home directory? |
1,409,919,431,000 |
Let's say I've got two repositories aye and bee and I want to get rid of bee, in such a way that the linear history of bee/master is "replayed" in a new subdirectory (several levels deep) of aye. I just want the files and the commit messages, I don't care about commit IDs. I do want a sensible history, so git subtree ... |
First, rewrite bee's history to move all files into the subdirectory:
cd /path/to/bee
git filter-branch --force --prune-empty --tree-filter '
dir="my fancy/target directory"
if [ ! -e "$dir" ]
then
mkdir --parents "${dir}"
git ls-tree --name-only "$GIT_COMMIT" | xargs -I files mv files "$dir"
fi'
git log --st... | How to replay Git repository history into subdirectory? |
1,409,919,431,000 |
The following works:
git -C ~/dotfiles status
But this fails:
git status -C ~/dotfiles
Why is this?
|
This is because -C is a global option, and doesn't "belong" to the status action. This is a common pattern, resulting in synopses like the one below:
command [global options] action [action-specific options]
git --help lists Git's global options, and man git goes into more detail.
| Why does position of -C matter in git commands? |
1,409,919,431,000 |
I want to create an inexpensive self-hosted private git server with redundant storage. To that end I have bought a Raspberry Pi and configured both git and ssh on the Pi. I can access the Pi both from a LAN and remotely (by forwarding a port on my router to the Pi).
So the git server is already up and running. The las... |
Q#1: Can you set up a RAID system using USB sticks as the storage media
You should be able to use any block storage devices in a RAID. Any standard directions for setting up a RAID using SATA HDD's should be applicable when using USB storage as well. You'll have to set it up so that the USB devices are assembled as ... | How to setup a RAID system using USB sticks as storage media |
1,409,919,431,000 |
I am trying to make an alias for mv so it does its normal behaviour in normal folders and is replaced by git mv inside git repositories. I tried many ways. The if statement works, only the command git mv will not run correctly.
alias mv='"$(
if [ x`git rev-parse --show-toplevel 2> /dev/null` = x ];
echo mv;
els... |
I would use a function for that, like so:
gitmv()
{
# If in a git repo - call git mv. otherwise- call mv
if [ x`git rev-parse --show-toplevel 2> /dev/null` = x ];
then
mv "$@"
else
git mv "$@"
fi
}
Edit:
alias mv=gitmv
| if-then-else inside Bash Alias |
1,409,919,431,000 |
I just made a simple script and created a new repository for it on GitHub. After initializing the local repo, moving the script to the repository and pulling the GitHub repository (containing only a README.md file), the script was gone. Is this normal behavior? And is there some way to restore the file?
Here are the c... |
A git pull will not overwrite local changes unless you use git add before. Even in this case, you can still recover your data.
When you issued git add before the pull:
mkgithub blub
cp test.sh blub/
cd blub/
git add test.sh
git pull
The pull will delete test.sh. It will only do this if you have no commit in the local... | Does git pull after init remove untracked files? |
1,409,919,431,000 |
I can do git clone like so ...
git clone https://github.com/stackforge/puppet-heat.git
... with no problems. But I want to exclude all the git meta stuff that comes with the cloning, so I figured I would use git archive but I get this error:
$ git archive --remote=https://github.com/stackforge/puppet-heat.git
fata... |
I would simply run the git clone as you've described and then delete the .git directories that are dispersed throughout the cloned directory.
$ find puppet-heat/ -name '.git' -exec rm -fr {} +
| git archive fatal: Operation not supported by protocol |
1,409,919,431,000 |
I have a custom Zsh function g:
function g() {
# Handle arguments [...]
}
Within it, I handle short arguments that execute Git commands. For example:
g ls # Executes git ls-files ...
g g # Executes git grep ...
I need to be able to set the autocompletion rules to Git's rules for the short arguments but I am unsu... |
I found /usr/share/zsh/functions/Completion/Unix/_git which had some tips for aliases like this and ended up defining these functions for the aliases:
_git-ls () {
# Just return the _git-ls-files autocomplete function
_git-ls-files
}
Then, I did a straight compdef g=git. The autocomplete system will see that you... | How do I set Zsh autocompletion rules for second argument (of function) to an existing command's rules? |
1,409,919,431,000 |
This is my Git repository:
https://github.com/benqzq/ulcwe
It has a dir named local and I want to change its name to another name (say, from local to xyz).
Changing it through GitHub GUI manually is a nightmare as I have to change the directory name for each file separately (GitHub has yet to include a "Directory ren... |
The fatal error message indicates you’re working from somewhere that’s not a clone of your git repository. So let’s start by cloning the git repository first:
git clone https://github.com/benqzq/ulcwe.git
Then enter it:
cd ulcwe
and rename the directory:
git mv local xyz
For the change to be shareable, you need to ... | Change a directory name in a Github repository remotely, directly from local Linux Git? |
1,409,919,431,000 |
Is it possible to use a commit message from stdout, like:
echo "Test commit" | git commit -
Tried also to echo the message content in .git/COMMIT_EDITMSG, but then running git commit would ask to add changes in mentioned file.
|
You can use the -F <file>, --file=<file> option.
echo "Test commit" | git commit -F -
Its usage is described in the man page for git commit:
Take the commit message from the given file. Use - to read the message from
the standard input.
| Git commit using stdout from bash? |
1,409,919,431,000 |
This is, how I download various master branches from GitHub, and I aim to have a prettier script (and maybe more reliable?).
wget -P ~/ https://github.com/user/repository/archive/master.zip
unzip ~/master.zip
mv ~/*-master ~/dir-name
Can this be shorten to one line somehow, maybe with tar and pipe?
Please address iss... |
The shortest way that seems to be what you want would be git clone https://github.com/user/repository --depth 1 --branch=master ~/dir-name. This will only copy the master branch, it will copy as little extra information as possible, and it will store it in ~/dir-name.
| Shortest way to download from GitHub |
1,409,919,431,000 |
I'm trying to get the most recent version of Git installed onto my Debian Buster machine, and I'm running into trouble. The most recent version of Git on stable is 2.20. I found that the testing branch has the right version, but I'm not having any success with backports. I've added
deb http://deb.debian.org/debian/ bu... |
Since February 2020, a new-enough version of git is available in Buster backports (2.30.2 since June 2021); to install that, run
sudo apt install -t buster-backports git
Readers who haven’t already enabled Buster backports will need to run
echo deb http://deb.debian.org/debian buster-backports main | sudo tee /etc/ap... | How do I get Git 2.24 installed on Debian Buster? |
1,409,919,431,000 |
When I view a large diff with git diff, it gets paged with less. This is confirmed by opening another window and checking data from ps -aux and /proc.
However, when less is invoked by Git, it does not revert the terminal content to its previous state after hitting q (the diff content remains in terminal). But when I ... |
Documentation:
When the LESS environment variable is unset, Git sets it to FRX (if LESS environment variable is set, Git does not change it at all).
The -X (--no-init) option is responsible for not clearing terminal after exit of less.
| `less` performs differently when invoked from Bash and from Git |
1,409,919,431,000 |
I have the following entries in a .gitignore file and I want to remove them. The reason why is because these files are temporary-junk files created during a TeX compilation and I want to be able to remove them.
How I can do that?
|
In your case if the files entries in your .gitignore are not starting with ! then this one-liner should be fine to you:
while read -r entry;do rm -rf ${entry}; done < .gitignore
| Delete any file mentioned in .gitignore |
1,409,919,431,000 |
Is there a way to tell git to only use so much bandwidth while cloning a repo?
I may have multiple applications - each of which demands different network speeds. Is there a way to tell git to do this? I only want to do it for this session, not every time.
|
Yes, there's always trickle. Install it, then try something like trickle -sd 50 git clone.
-s is for standalone mode, -d is for download limit, in KB/s
| Is there a way to throttle git while it's cloning a repo? |
1,409,919,431,000 |
I'm using bash version 4.1.2(1)-release (x86_64-redhat-linux-gnu) on cygwin with git 1.7.1. I wanted to make an alias for a command that needed to use the input argument twice. Following these instructions, I wrote
[alias]
branch-excise = !sh -c 'git branch -D $1; git push origin --delete $1' --
and I get this error... |
man git-config says:
The syntax is fairly flexible and permissive; whitespaces are mostly
ignored. The # and ; characters begin comments to the end of line,
blank lines are ignored.
So:
branch-excise = !bash -c 'git branch -D $1; git push origin --delete $1'
is an equivalent to:
#!/usr/bin/env bash
bash -c 'gi... | Errors with git alias shell command |
1,409,919,431,000 |
I have a folder with several repositories inside. Is there any way I can run git branch or whatever git command inside each folder?
$ ls
project1 project2 project3 project4
And I'd like to have some kind of output like the following
$ command
project1 [master]
project2 [dev]
proje... |
Try this. $1 should be the parent dir containing all of your repositories (or use "." for the current dir):
#!/bin/bash
function git_branches()
{
if [[ -z "$1" ]]; then
echo "Usage: $FUNCNAME <dir>" >&2
return 1
fi
if [[ ! -d "$1" ]]; then
echo "Invalid dir specified: '${1}'"
... | Get git branch from several folders/repos |
1,409,919,431,000 |
I'm recently trying to start my own project on a community git repo, and I've been having some complications. I'm new to git, but here's what I've been trying to do to just test it.
I run the following commands and they all run ok.
git config --global user.name "MYNAME"
git config --global user.email "MYEMAIL"
mkdir t... |
That the remote declined to receive the data is only a side effect of the real problem -- git thinks that it was denied because one of the hooks on the remote end failed with an exit status >0 (you can see what it was in the Ruby traceback). It seems that one of the hooks tries to use rake, and can't find it. This is ... | git push fails with remote: error: hook declined to update refs/heads/master |
1,409,919,431,000 |
I'm looking for a tool, or for suggestions towards a script, that would be able to search a Git repository for files based on both filenames and file contents (find/grep-like). It would need to be able to search not just in the currently checked out branch, but through that branch's history as well as in other branch... |
Heh, guess what I’ve been doing too...
To look for a file name across all branches, I use
git log --all --name-only --pretty=format:%H -- wow\*
wow can be replaced by any glob. This runs quite quickly on the Unix history repository. The format shows the hash leading to the creation of the matching file, so you can th... | Tool for searching across branches and through history in a Git repository |
1,610,403,173,000 |
I have a problem with the certificates in Arch linux. It seems that it can't find ca-certificates.crt. I have updated my system and installed the ca-certificates{,-utils,-mozilla} packages and it still doesn't work.
git clone http://github.com/sstephenson/bats.git
Cloning into 'bats'...
fatal: unable to access 'https:... |
I am posting an answer to my own question because I solved the problem and I did not find a valid solution elsewhere. There is no /etc/ssl/certs/ca-certificate-crt file. So a link needs to be provided to the proper cert.
$ ln -s /etc/ca-certificates/extracted/ca-bundle.trust.crt /etc/ssl/certs/ca-certificates.crt
Now... | Arch linux ca-certificates.crt not found |
1,610,403,173,000 |
-n works as a grep argument to display the line number, but -H doesn't for filename. I think it is because git diff doesn't by default output filename for each changed line. As I was typing, I considered another option to display multiple lines and it solved my immediate problem, but would still like to know the sol... |
I’m not sure you can show both the filename and the changed line in a single command, but the following will list all files where a line containing this->config has changed:
git diff --name-only -G"this->config"
| Display filename of git diff filtered by term |
1,610,403,173,000 |
so git archive --format=tar HEAD will give me a tar archive of the latest commit on the current branch. Is there a version that would include local modifications to tracked files that have not yet been committed?
|
The git way is to commit everything. Remember, branches are cheap.
git checkout -b intermediate-releases/20140414
git commit -m 'Wibble wobble wubble'
Then restore your working copy — I don't know to do that reliably but I'm sure there's a way. Now you can make an archive of the new branch's tip:
git archive intermed... | git archive including uncommitted modified files |
1,610,403,173,000 |
How do I select all the files ending with .txt in the current directory, but omit all the ones in the subdirectories?
*.txt selects all the files ending in .txt in the subdirectories as well. How do I omit them?
directory structure:
current folder
|-first_file.txt
|-sub_folder
|-second_file
I'm trying to add the f... |
There is a subtle difference between whether the shell or git handle the pattern. git considers subdirectories as well, the shell doesn't. So in your case, running
git add *.txt
while the current directory is your "current folder" lets the shell do the wildcard expansion (and therefore only adds matching files in the... | How can I get git to select txt files in the current directory alone |
1,610,403,173,000 |
I find both of these can unstage a file.
I used to use git reset file to unstage a file.
But today when I read the http://git-scm.com/book.
I find it taught me to use git reset HEAD file, what does the HEAD do here? In which circumstances it's a must?
PS: An additional question, I can use git checkout file to unmodif... |
There's no difference. HEAD is entirely optional. HEAD normally points to the last commit of the current branch. If you don't use it, it's implied. It makes sense only if you want to reset file based on some different branch or commit etc. In other words, it makes sense to use something else than HEAD.
git checko... | What's the difference between `git reset file` and `git reset HEAD file`? |
1,610,403,173,000 |
I have a corporate Linux server which does not have internet connection, and sudo access needs to be approved through many levels of hierachy. I've tried install git but I soon realized this needs a whole bunch of dependencies like C compiler to install, of which I do not have the dependencies.
What I need is a method... |
I found a solution that works. To iterate my steps:
1) Download relevant RPM (or here)
2) Copy to Linux server and upack using (replace filename as
necessary)
rpm2cpio git-1.7.9.6-1.el6.rfx.x86_64.rpm | cpio -idmv
3) Update $PATH:
PATH=$PATH:<your path to git>/usr/bin
4) Now see it work
git --version
| Install Git offline without sudo |
1,610,403,173,000 |
I'm used to create some manually-made repositories to push code to my pet server or share code inside my company. I use the URL ssh://user@ip/folder.git to add as remotes to my workspaces.
I was wondering how services like GitHub set repository URLs without the protocol spec, like [email protected]:igorsantos07/Restle... |
If you take a look at the Git book accessible here: 4.1 Git on the Server - The Protocols there is mention of the various formats for the protocols that Git will accept.
excerpt
Probably the most common transport protocol for Git is SSH. This is because SSH access to servers is already set up in most places — and if ... | Is it possible to remove "ssh://" from git remote's URLs? |
1,610,403,173,000 |
In my zsh shell, I am dynamically changing prompt depending on whether I am inside git repository or not. I am using following git command to check:
if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then
...
now I also want to distinguish whether current directory is being ignored by git. So I have added one... |
git check-ignore . will fail with exit code 128 if . isn’t in a git repository (or any other error occurs), and with exit code 1 only if the path isn’t ignored. So you can check for the latter only:
git check-ignore -q . 2>/dev/null; if [ "$?" -ne "1" ]; then ...
Inside the then, you’re handling the case where . is ... | zsh prompt: check whether inside git repository and not being ignored by git |
1,610,403,173,000 |
${$(git rev-parse HEAD):0:5}
bash: ${$(git rev-parse HEAD):0:5}: bad substitution
git rev-parse HEAD returns the hash id, but how do I make a substring out of it?
if I divide it into two lines, it works.
x=$(git rev-parse HEAD)
echo ${x:0:5}
But How do I do it in one line?
|
Using --short option:
$ git rev-parse --short=5 HEAD
90752
$ x=$(git rev-parse --short=5 HEAD)
$ printf '%s\n' "$x"
90752
| How to get first 5 chars of a git commit hash id and store it in a variable in bash? |
1,610,403,173,000 |
Whenever I try to create a signed git commit, I need to enter my GPG key. It spawns some GUI application to receive the password. It looked like the application was seahorse, so I uninstalled it, but git still uses some GUI app. Polybar doesn't report the application name and it's title is just [process]@MYPC.
How do ... |
What's in your ~/.gnupg/gpg-agent.conf?
I have pinentry-program /usr/bin/pinentry-curses in mine, and everything which uses gpg will ask for my pass-phrase in the terminal.
NOTE: You will need to restart your gpg-agent (or send it a HUP signal) if you change its config. Just running gpgconf --kill gpg-agent will do, ... | How do I get git to use the cli rather than some GUI application when asking for GPG password? |
1,610,403,173,000 |
I have a Makefile for a Latex project I'm working on. Makefiles aren't my forte, but is there a way to do something like:
make git "My comment"
And have the makefile execute:
git commit -m "My comment"
git push origin master
?
|
You could use a variable and read it from within the Makefile. Example:
git:
git commit -m "$m"
Then you can commit with: make git m="My comment".
| Git commit from within a Makefile |
1,610,403,173,000 |
I am using Git as many of you do. Also, I don't use any GUI for that — just CLI. So I was wondering: are there any way to make Git commands (git status, git checkout etc.) complete themselves when hitting Tab? Like other CLI commands do.
P.S. I'm using Arch Linux, if that anyhow matters.
|
Add source /usr/share/git/completion/git-completion.bash to your ~/.bashrc.
References
Arch Linux Wiki
| Git auto-complete |
1,610,403,173,000 |
I would like to use git to track changes in crontab.
I have initialized a new git repository in /var/spool/cron/crontabs/
Now the problem is, when crontab is saved, the second line of the header changes because it contains timestamp.
# DO NOT EDIT THIS FILE - edit the master and reinstall.
# (/tmp/crontab.ubNueW/cront... |
You could use a filter:
git config filter.dropSecondLine.clean "sed '2d'"
Edit/create .git/info/attributes and add:
* filter=dropSecondLine
If you don't want the filter acting on all the files in the repo, modify the * to match an appropriate pattern or filename.
The effect will be the working directory will remain ... | tracking crontab changes with git |
1,610,403,173,000 |
The example below is simplified to show the core of the problem, not the problem itself(my file tree is more complicated than that).
Let's say that I have two files I want to back up; one in ~/somedir/otherdir, the other in ~/otherdir/somedir/. I want to backup files from both directories in one git repository. How ca... |
If you don't mind moving the files...
You could do this by moving the files into a git repository, and symlinking them to their old locations; you'd end up with
~/gitrepo/somedir/otherdir/file1 moved from ~/somedir/otherdir/file1
~/gitrepo/otherdir/somedir/file2 moved from ~/otherdir/somedir/file2
a symlink from ~/so... | How to backup files in multiple directories with git? |
1,610,403,173,000 |
I host my own git repository on a VPS. Let's say my user is john.
I'm using the ssh protocol to access my git repository, so my url is something like ssh://[email protected]/path/to/git/myrepo/.
Root is the owner of everything that's under /path/to/git
I'm attempting to give read/write access to john to everything whi... |
create a group myrepousers for example, and add your git users to that group.
Then change the group of everything under /path/to/git/myrepo to myrepousers:
chown -R .myrepousers /path/to/git/myrepo
Then fix the permissions:
chmod -R g+w /path/to/git/myrepo
find /path/to/git/myrepo -type d -exec chmod g+s {} \;
Shoul... | How to grant read/write to specific user in any existent or future subdirectory of a given directory? |
1,610,403,173,000 |
I need to copy a SINGLE FILE from LOCAL REPOSITORY to my machine, not git-pull or git-fetch, how can i do it?
Is it possible to get it via hash ?
such as a3ea2118bf1c5e2c6aa0974d0b6ff7415bd044ef ?
|
You can use git archive to obtain a single file from a repository:
git archive --remote=file:///path/to/repository.git HEAD:path/to/directory filename | tar -x
The repository specified as --remote can be local, remote, bare or regular, it works in all of the aforementioned cases.
Note that if you want to obtain a ver... | copy a single file from local Git repository |
1,610,403,173,000 |
I want to download the patch series RFC PATCH 00/26 i.MX5/6 IPUv3 CSI/IC
In patchwork I can get access to individual patches https://patchwork.linuxtv.org/patch/24331/. But downloading 26 patches and then applying them one by one gets tedious. Is there a way to download the complete patch series with patchwork or by o... |
The patchwork project information page at https://patchwork.linuxtv.org/project/linux-media/ has a couple of links at the bottom to pwclient and a sample .pwclientrc
Once you set these up, you can use pwclient list to search for patches and pwclient git-am to apply them. The awkward part is that there's apparently no ... | How download complete patch series from patchwork? |
1,610,403,173,000 |
My configuration:
laptop: XPS 15 7590
system: Ubuntu 18.04
internet connection: wifi (5 GHz)
Every time I run git pull, git push I have to wait like 15 minutes until it is done. Same problem with running add-apt-repository ppa. As I was trying to solve it, I found this question where the solution was running:
sudo s... |
In order to make this permanent, open your /etc/sysctl.conf file using sudo
sudo nano /etc/sysctl.conf
Add the line at the bottom of the file:
net.ipv6.conf.all.disable_ipv6=1
After that you may reboot your machine or run
sudo sysctl -p
Alternatively, you may instruct your ssh client to use ipv4 only. To do so, op... | Git push/pull taking too long - IPv6 issue |
1,610,403,173,000 |
I have a script with this snippet:
ssh-agent bash -c "ssh-add $SOME_KEY; \
git submodule update --init foo"
The script hangs while asking the user:
RSA key fingerprint is SHA256:[the fingerprint]
Are you sure you want to continue connecting (yes/no)?
How can I make the script continue (with a yes... |
From Stack Overflow, via muru, passing ssh options to git clone:
The recently released git 2.3 supports a new variable
"GIT_SSH_COMMAND" which can be used to define a command WITH
parameters.
GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" git clone user@host
$GIT_SSH_COMMAND t... | How can I suppress host key checking with ssh-agent |
1,610,403,173,000 |
From the git-revert(1) manpage it is not clear to me what the exact differences between the quit and abort options of the revert command are.
From my exercises with the revert command I made the observation that the abort option works very similar to the one of the rebase command in that it tries to reconstruct the pr... |
From my exercises with the revert command I made the observation that the abort option works very similar to the one of the rebase command in that it tries to reconstruct the pre-operational state of the current branch.
You're on the right track:
git revert --abort rolls the sequencer state back, so the workspace a... | What is git revert --quit for? |
1,610,403,173,000 |
I manually installed git 1.6 a year or two ago.
I noticed today that the 1.7 version is available in yum, and installed it (package git-all)
I now get the following output:
[root@ovz5197 ~]# git --version
bash: /usr/local/bin/git: No such file or directory
[root@ovz5197 ~]# which git
/usr/bin/git
[root@ovz5197 ~]# /us... |
If you had already run git from this instance of bash back when there was a /usr/local/bin/git, it's remembering the old location in a cache. Run hash -r to clear the cache. Each instance of bash has its own cache, so newly started instances of bash will look in the right place.
Otherwise, you evidently have a file /u... | Multiple installed versions of git - centos |
1,610,403,173,000 |
Is there a way to make git handle a symlink as if it was a file. If I just normally add a symlink like git add symlink, git just stores/controlls the path to the file, not the linked file.
Is it possible to make git handle a symlink as if it was the linked file itself?
|
Sounds like you want a hard link
ln sourcefile /some/git/repo/targetfile
Only any good if the source and target locations are within the same file system. Otherwise you’ll have to settle for a copy or a symlink.
A symlink is a reference to a file.
A hard link is another name for an existing inode.
There are numerous ... | Git - handle symlink as if it was a file |
1,610,403,173,000 |
In zsh I am using the following function to delete a local and a remote branch with one command:
gpDo () {
git branch -d "$1" && git push --delete origin "$1"
}
Currently, auto-completion for the Git branch does not work. I have to manually type the whole branch name. How can I get tab completion working for such... |
I assume you're using the “new” completion system enabled by compinit. If you're using oh-my-zsh, you are.
You need to tell zsh to use git branch names for gpDo. Git already comes with a way to complete branch names. As of zsh 5.0.7 this is the function __git_branch_names but this isn't a stable interface so it could ... | zsh: Tab completion for function with Git commands |
1,610,403,173,000 |
After I clone a git repository locally, I want to switch branch to, says, 'ABCD'.
$ git branch -a
* master
remotes/origin/ABCD
remotes/origin/HEAD -> origin/master
remotes/origin/master
$ git checkout origin/ABCD #### <- Here is the problem!
Note: checking out 'origin/ABCD'.
You are in 'detached HEAD' state.... |
I found a great plugin for zsh that you can use. If you are using oh-my-zsh then its called gitfast or if just using zsh then you can follow the instructions on his blog article.
As the author details there are in fact quite a lot of git completion issues and his efforts are to resolve them all. This is one issue that... | zsh git command auto-complete add extra origin to the git branch name |
1,610,403,173,000 |
I have a machine running Ubuntu with a SSH config file in ~/.ssh/config with the following permissions (default when creating a new file)
-rw-rw-r-- 1 dev dev 75 Oct 26 20:13 config
After creating a new user (test) with the same primary group (dev) as the existing user (dev), I am no longer able to git clone when ... |
In the openssh-7.6p1 source code file readconf.c we can see that the permission checking is delegated to a function secure_permissions:
if (flags & SSHCONF_CHECKPERM) {
struct stat sb;
if (fstat(fileno(f), &sb) == -1)
fatal("fstat %s: %s", filename, strerror(errno));
if (!secur... | Creating a new user breaking existing permissions |
1,610,403,173,000 |
git commit can fail for reasons such as gpg.commitsign = true && gpg fails (for whatever reason). Retrying the command opens a blank editor; the message is lost.
When this happens, is there any way to recover the written commit message, to retry committing with the same message?
|
From man git-commit:
FILES
$GIT_DIR/COMMIT_EDITMSG
This file contains the commit message of a commit in progress. If git commit exits due to an error before creating a commit, any commit message that has been provided
by the user (e.g., in an editor session) will be available in this file,... | Is git commit message recoverable if committing fails for some reason? |
1,610,403,173,000 |
I'm looking for a way to get three informations from a remote repository using git ls-remote like command. I would like to use it in a bash script running in a cron. Currently, if I do
git ls-remote https://github.com/torvalds/linux.git master
I get the last commit hash on the master branch :
54e514b91b95d6441c12a795... |
While there is not any utilities that come with git that lets you do what you want, it is rather easy to write a python script that parses a git object and then outputs the author and commit message.
Here is a sample one that expects a git commit object on stdin and then prints the author followed by the commit messag... | Get last commit message, author and hash using git ls-remote like command |
1,610,403,173,000 |
I accidently ran an rm -r on my .git directory. Luckly rm stopped when it got to a write-protected file, but I've still lost several things in my .git.
Files I still have:
FETCH_HEAD
ORIG_HEAD
config
gitk.cache
logs/
objects/
Files I've lost:
HEAD
description
hooks/
index
info/
packed-refs
refs/
From what I can tell... |
All of the commits and the files that they reference would be stored as objects
in the objects directory. Git creates those as read-only, so they should all
still be present.
To recover, I'd advise creating a new, empty repository and copying the
contents of your broken repository's objects directory into that of ... | How to recover broken/partially deleted git repository |
1,610,403,173,000 |
Usually, git aliases are confined to a single command:
git config --global alias.ci commit
So, instead of git commit you could do git ci
But it seems you can insert a function in there as well:
git config --global alias.up-sub '!f() { cd $1 && git checkout master && git pull && git submodule update --init --recursive... |
Looks like a regular shell function definition and invocation. Only the bang stands out, but a quick search through the git-config(1) manual shows an explanation:
If the alias expansion is prefixed with an exclamation point, it will be treated as a shell command. For example, defining "alias.new = !gitk --all --not O... | How does this git alias work? |
1,610,403,173,000 |
A history
I installed etckeeper
I decided to track e.g. shorewall firewall configuration as its own git repository. I think I wanted it to be easier to look at specific configuration changes. I decided I did not need etckeeper any more and uninstalled it. So no conflict, except...
While re-considering etckeeper, I... |
My first tests with nested git repositories didn't suffer any of those three problems. You don't have to add .git in gitignore; the contents of all .git directories are ignored automatically.
The other files (e.g. in the same directory as .git) can be committed in the outer repository.
So I thought etckeeper could ke... | I have nested git repos, will it cause a problem? |
1,610,403,173,000 |
I have a RHEL 6.4 VM provisioned by my company's internal KVM.
We are having some trouble using yum (Cannot retrieve repository metadata, which I've confirmed in this case is peculiar to my company's internal cloud), so I have to build Git from source.
Downloading the RPM file and issuing
sudo yum localinstall ....rpm... |
I think I would suggest not installing these items from source directly but rather harness the power of your package manager to still maintain these packages.
locally installing
You can use a command line tool such as curl or wget to still download the packages necessary to install them either using yum or rpm direct... | Installing Git, Curl, and Expat from Source |
1,610,403,173,000 |
Using command="" in authorized_keys, I can restrict the commands that can be run by a particular key.
What commands do I need to allow in order to have a functioning git remote?
From the Pro Git book I can infer that git-upload-pack and git-receive-pack are required, but is there anything else?
Note I still want to be... |
Git includes a git-shell command suitable for use as a Git-only login shell. It accepts exactly the following commands:
git receive-pack
git upload-pack
git upload-archive
git-receive-pack
git-upload-pack
git-upload-archive
cvs server (used for emulating a CVS server, and not required for the Git protocol... | What commands does git use when communicating via ssh? |
1,610,403,173,000 |
Every time I try to make my Zsh history file (.zhistory file) a symbolic link to a file (previously existing .zhistory file) that lives in another folder, Zsh deletes the symbolic link and makes it a regular file.
I have tried creating the symbolic link in Bash and then switching back to Zsh, but Zsh will still always... |
The easiest way to do this would be to not use links at all. The location of the zsh history file is determined by the value of $HISTFILE. So, to have that backed up, change it from the default value to a file in the watched directory. Add this line to your .zshrc:
HISTFILE=~/foo/.zhistory
Now, copy the existing file... | Unable to make .zhistory a symbolic link |
1,610,403,173,000 |
Please forgive me if this seems easy, but I only started learning Unix 2 days ago.
Basically, I have been taught that when typing a command into the terminal it needs to be of the form:
[command name][space][-options][space][arguments]
Now I've just started looking at using git, and I've come across the following:
gi... |
It is a good starting point, but "generally" needs to be emphasized. For utility commands it is always a good idea to read the man utility page for what is correct syntax.
There is a guideline at The Open Group that can be worth a read. However there is varying level of how conforming implementations are. Some impleme... | Bash commands with spaces in them (git config or git-config?) |
1,610,403,173,000 |
I have git configured (like below) to use vimdiff as difftool and compare another pair of files without prompting as soon as I call :qa. It's awesome. The only problem is sometimes there are differences in many files. How do I prevent git from running another vimdiff instance and continuing the diffs queue?
git config... |
I found a possible solution from another question, “How do you cancel an external git diff?”
Try running:
git config --global difftool.trustExitCode true
git config --global mergetool.trustExitCode true
and then exiting with the non-zero :cq.
| How to prevent `git difftool` from calling another `vimdiff`? |
1,392,755,257,000 |
How can I produce a list of filenames (incl. paths) that git knows about over the course of the whole history?
|
Naive solution:
git rev-list --all | xargs -n1 git ls-tree --full-name -r --name-only | sort -u
This lists all commits, then uses that to list all files in every commit. sort deduplicates. Only works for small-ish repos though as it takes a long time.
A better solution would be to use libgit2 to do the same, should ... | How to show all files git knows about? |
1,392,755,257,000 |
I occasionally need to grep through git submodules for which I use:
git submodule foreach 'git grep x'
However, since switching to zsh I find a less prompt is opened for each submodule, even when there are no options. What I'd much prefer is for all of the output to be printed out to the terminal.
My current solution... |
Try changing the pager that git uses:
GIT_PAGER="cat" git submodule foreach 'git grep x'
Or if you want less to be used, but only when output will run off of the screen:
GIT_PAGER="less -FX" git submodule foreach 'git grep x'
You can set the pager per project by using git config, or you can, of course, set the envir... | Stop Git submodule foreach from opening less for each module |
1,392,755,257,000 |
Long story short: I've used only distributions with "imperative configuration management/packaging" approach, so far. And,... I'm annoyed by hard to trace breakages/issues with imperative configuration management (when experimenting).
I've found NixOS, which advertises:
NixOS has a completely declarative approach to ... |
The NixOS configuration consists of two files (although you can break it up into more files): configuration.nix and hardware-configuration.nix.
Both files are stored in /etc/nixos and they are text files. Hence, you can certainly put them in a GIT repo.
| Can I manage my NixOS configuration in version control like git? |
1,392,755,257,000 |
I'm running bash
GNU bash, version 4.3.25(1)-release (x86_64-apple-darwin13.4.0)
on OS X 10.10.1. A week or so ago I've noticed that autocompletion has stopped working, but only for git. I'm using this script for git autocompletion:
https://github.com/git/git/blob/master/contrib/completion/git-completion.bash
Few d... |
These strange escape sequences are color-changing commands.
The completion code runs the following command to list available commands:
git help -a|egrep '^ [a-zA-Z0-9]'
The output of git help -a looks like this:
add grep remote
add--interactive hash-object ... | Strange characters in GIT completion |
1,392,755,257,000 |
I have an SSH server running on my Raspberry PI with ALARM (up to date).
My user "gitroot" is meant to use the git-shell. However, when I set /usr/bin/git-shell as shell for gitroot in /etc/passwd, I can't login with that user anymore. su - gitroot works as expected. When I change the shell to /bin/bash, I can login a... |
As mentioned in the comments, you should add /usr/bin/git-shell to /etc/shells.
| SSH: "Permission denied" after changing user shell |
1,392,755,257,000 |
I'm trying to setup a linter for my code and I only want to lint the coffeescript files that have changed in the current branch. So, I generate the list of files using git:
git diff --name-only develop | grep coffee$
That gives me a nice list of the files I'd like to process but I can't remember how to pipe this to t... |
xargs is the unix utility I was looking for. From the man page:
The xargs utility reads space, tab, newline and end-of-file delimited strings from the standard input and executes utility with the strings as arguments.
Any arguments specified on the command line are given to utility upon each invocation, followed by ... | How can I pipe stdout to another program? |
1,392,755,257,000 |
I am trying to install git on my Red Hat Enterprise Linux 6.5 server and have hit a brick wall. I can't find the package dependencies for git using yum.
[root@FOOBAR mydir]# yum install curl-devel expat-devel gettext-devel \
> openssl-devel zlib-devel
Loaded plugins: product-id, refresh-packagekit, secur... |
It seems that you didn't register with RHN, so you are unable to download from Redhat's base repo.
You can't get Redhat official packages without registering.
If you don't have RHN credentials, you can use the Centos base repo instead. See this link for more details.
| No package * available. cannot install git through yum |
1,392,755,257,000 |
I have some markdown files but I can't git diff them.
No result at the command line and not supported in gitg (visual git)
Is that possible with the files as they are, without converting them to something else?
|
It should work fine; markdown files are plaintext files, so git diff is perfect.
This could be one of a few possible things:
There is no difference in the file (empty output).
The changes to the files have not been added (git add -p *.md)
What does git status say? If it doesn't contain a few lines that say something... | How can I git diff markdown (.md) files |
1,392,755,257,000 |
The vc bundle is a neat little package that extracts information about a git repo for easy insertion into a LaTeX document. It doesn't currently extract information about whether the current commit is tagged and what the tag name is. How would I edit the vc script to do this?
And then how would I edit the vc-git.awk s... |
git log --decorate -1 [commit]
If commit (HEAD if omitted) has tags, the commit hash will be followed by (tag: name) (and possibly multiple other symbolic references too). You can pick this out more specifically with
git log --pretty=%d
| extracting "tag" information from git with a shell script |
1,392,755,257,000 |
Can I display GIT in prompt when current directory has/contains a .git folder? Is there a way to do this? My current prompt is defined like so:
export PS1="[\u@\h] \w $ "
So, my prompt looks like this:
[user@computer] ~/workspace $
And I want it to dynamically look like this:
[user@computer] ~/workspace GIT $
|
The most standard way is to use __git_ps1 directly from git. In Ubuntu, it is available in this path:
source /usr/lib/git-core/git-sh-prompt
## source /etc/bash_completion.d/git-prompt
#PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w $(__git_ps1 "(%s)")\$ '
You can ... | Can I display GIT in prompt when current directory has a .git folder? |
1,392,755,257,000 |
If I install a git-package via packer or pacaur, then it will pull the current source-tree of the repo, compile, and install it.
But how are updates handled? Is there a specific way to upgrade all my AUR-Git Packages?
|
In addition to jasonwryans excellent answer: Most AUR helpers have a flag to update development packages, even if their pkgver hasn't changed in the AUR. For pacaur, that flag is called --devel which can be used in conjunction with its update operations. It will cause pacaur to rebuild development package, but only if... | How package managers update packages installed using git-packages? |
1,392,755,257,000 |
I have a bunch of raspberry pis running Ubuntu 20.04 server, that I wish to update automatically via Git, non-interactively.
The script does the following:
eval "$(ssh-agent -s)" ; ssh-add /home/michael/.ssh/terminal_github_deploy_key ; git -C /home/michael/terminal/src pull
The script is actually in Python, but does... |
Without writing another script in something like expect, you will not be able to do that while being vanilla.
The easiest way to do so is to add the Github Host Keys to
.ssh/known_hosts
EDIT: Due to the fact that there is a lot of servers, this is not possible, what is on that site is not individual host keys
Otherw... | Automate git pull with ssh authentication via a script (non-interactive) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.