date int64 1,220B 1,719B | question_description stringlengths 28 29.9k | accepted_answer stringlengths 12 26.4k | question_title stringlengths 14 159 |
|---|---|---|---|
1,392,755,257,000 |
On FreeBSD 10.3, I run a command like git show on xterm, the output contains some strange irrelevant characters as below. I'm not sure why.
|
Your pager seems to be configured to render the Esc character (used in escape sequences to change the text colour) as ESC instead of passing it directly to the terminal (that's independent from the terminal emulator, in your case xterm).
Try setting (sh syntax).
PAGER=less LESS=R
export PAGER LESS
Or ((t)csh syntax):... | "git show" shows strange characters on XTerm |
1,392,755,257,000 |
What would be the best way to set Vim up to always put the cursor in insert mode at the end of the first line (to account for commit message templates) when running git commit? This would basically do something identical to pressing ggA every time. Ideally this should be a Vim configuration (presumably in ~/.vim/after... |
Adapting one of the autocommands given in the Vim Wikia, this seems to work fine with git commit -t /tmp/COMMIT_EDITMSG for me:
" ~/.vim/ftplugin/gitcommit.vim
au! VimEnter COMMIT_EDITMSG exec 'norm gg' | startinsert!
I used exec 'norm gg' | instead 1 | because :1 | is equivalent to :1p | and there's a small delay as... | How to start Vim in insert mode at end of first line when committing Git changes? |
1,392,755,257,000 |
I known using git on the command line is the preferred method by a lot of Linux users.
But has somebody have successfully installed and used a Git Client with GUI on Debian Based System? (to be precise it is a Raspberry PI 2 with raspbian distro)
I am asking that question, because I didn't find any answer on Web, and... |
git itself provides a GUI, which in Debian derivatives, including Raspbian, is packaged as git-gui. Install that, and you’ll be able to run git gui to perform most operations. You can also install gitk to explore repositories in a GUI.
To resolve merge conflicts, I quite like Meld, but that pulls in part of GNOME so i... | Git Client with UI on a Debian system |
1,392,755,257,000 |
I needed to reset my branch to an earlier working state (commit) so I did:
git reset --hard c70e611
Now I see
HEAD detached at c70e611
nothing to commit, working directory clean
How to fix / understand / get around the detached head message and push so that c70e611 is now the latest commit I am using and represents... |
HEAD detached at c70e611
This is because when you did the git reset --hard, you were not on any branch at that time. You had a detached HEAD, and that detached head got moved with the git reset --hard command, along with a rewrite of your working tree to that state.
If you want some branch foo to be c70611, then:
gi... | How do I reset a git branch to a given previous commit and fix the detached HEAD? |
1,392,755,257,000 |
I had to install git from source on RHEL. After installation the git command is shown to be in /usr/local/bin/git when trying the whereis command.This path is available in $PATH also.
When I type git it still says "Command not found."
How to resolve this?
EDIT : output of various commands
$type git
type: Command not... |
From the error messages you're using (t)csh. It would help to mention it in your question, especially as you're showing $ as your prompt, and that's traditionally a Bourne prompt, not a csh prompt.
type is a builtin in Bourne-style shell. It doesn't exist in csh. When you run type git, it tells you that the type comma... | git command not found |
1,392,755,257,000 |
consider:
$ git --version
git version 2.20.1 (Apple Git-117)
$ git diff-index --quiet HEAD ; echo $?
1
$ git status > /dev/null
$ git diff-index --quiet HEAD ; echo $?
0
This is on macos with a case-insensitive file system. (I don't know that that is relevant.) On the host where this occurs, there is a docker image... |
I've had a similar problem with git diff-files and I think the cause was the same. This doesn't need to involve Docker or case-insensitive filesystems, although these may exacerbate the problem.
Git maintains a cache of information about the content of files. Normally, this is transparent, and high-level commands such... | Why does executing `git status` change the result of subsequent `git diff-index`? |
1,392,755,257,000 |
How do I tell my zsh to automatically try a command with git in front, if the command is not found? E.g. I want to run $ status and if there is no status in $PATH, my zsh should try git status.
|
This sounds fragile — you could get into the habit into typing foo instead of git foo, and then one day a new foo command appears and foo no longer invokes git foo — but it can be done. When a command is not found with normal lookup (alias, function, builtin, executable on PATH), zsh invokes the command_not_found_hand... | how do I call git commands without 'git ' in front? |
1,392,755,257,000 |
I'm trying to find and list down all commits made between two Linux kernel releases/tags (between Linux kernel 4.4.0 and 4.9.273), inside the git clone of the official Linux kernel repo.
Which git command or software tool can help me achieve this ?
|
Generally, to list commits, use git log. There are other commands that list commits, but they're for purposes more exotic than what you want.
“Commits made between two [commits]” is a revision range. The commits in question are the tags v4.4 and v4.9.273. Here you're looking for the commits that are in some revision b... | Find all commits between two Linux kernel releases |
1,392,755,257,000 |
I'm thinking about setting up a cronjob for fetching all my repositories every once in a while, to have the current status ready in case I'm offline. Something like the following (wrapped for better readability):
find $HOME -name .git -type d -printf "%h\0" |
parallel --gnu -0 --delay 0.2 --jobs 100 --progress \
'... |
I've been fetching my local Git repos in the background for two years now, without any sign of trouble. Currently, crontab contains something like
savelog -n -c 400 ~/log/git-fetch.log
find ~/git -type d -execdir [ -d '{}/.git' ] \; -print -prune |
parallel --gnu --keep-order \
"date; echo {}; cd {}; git fetc... | Fetching all Git repositories in the background |
1,392,755,257,000 |
I'd like to install latest available git to day (git-2.17.1), on CentOS 7.4, because some applications are complaining for it, and not only.
I'm trying to install git-2.17.1 from source on CentOS 7.4.
These are the approachs I tried:
Uninstalled the old git (only) using:
a) rpm -e --nodeps git
Downloaded and extrac... |
That's not error, you can check it with echo $? after running make install-info. Target install-info in Documentation/Makefile
looks like this:
install-info: info
$(INSTALL) -d -m 755 $(DESTDIR)$(infodir)
$(INSTALL) -m 644 git.info gitman.info $(DESTDIR)$(infodir)
if test -r $(DESTDIR)$(infodir)/dir; then... | How to correctly install Git 2.17.1 from source on CentOS 7.4? |
1,392,755,257,000 |
I'm trying to install hhvm-git package from AUR and getting an error. There is a bug in one of submodules. This bug is fixed already and I want to specify revision contains that fix for the submodule. How can I do that?
In PKGBUILD I tried to specify revision as suggested in Arch Wiki (line in source array):
"git+http... |
I specified revision in wrong format. Correct format in my case is:
"git+https://github.com/facebook/proxygen#commit=7e37f926d922b55c85537057b57188dea9694c32"
From man PKGBUILD:
USING VCS SOURCES
Building a developmental version of a package using sources from a version control system (VCS) is enabled by specifying t... | Specify submodule revision in PKGBUILD |
1,392,755,257,000 |
I have a git repository with 2 branches:
$ git branch
* master
test/branch
I can list specific branches individually by doing the following:
$ git branch --list master
* master
$ git branch --list test/branch
test/branch
However, when I store this command as a variable, I get unexpected results:
$ LOCAL=$(git ... |
Above, it looks like Bash is expanding the * which appears at the start of $LOCAL. Try echo "$LOCAL".
| Storing git results in a variable results in weird behaviour [duplicate] |
1,392,755,257,000 |
I'm using this simple git alias
rmdel = "!git rm $(git ls-files -d)"
meant "remove deleted", i.e. to remove from the staging area all files deleted from the file system. It works fine except when there are any files containing blanks. Then obviously the list gets split on them as well leading to file names of non... |
ls-files has a switch designed for this purpose, -z:
-z \0 line termination on output.
xargs has a switch to let you separate input items by a null character instead of whitespace, -0. Combining them, you get:
$ git ls-files -dz | xargs -0 git rm
| Git - remove deleted files |
1,392,755,257,000 |
I have a LXC container on my Debian system. I want to setup a public Git server on it so that it's accessible to other people. How can I do this?
UPDATE #1
Link to apache2.conf: http://pastebin.com/Nvh4SsSH.
|
Give this Howto a look. It's a little dated but should have the general steps you need to setup a Git server. The howto is titled: How To Install A Public Git Repository On A Debian Server.
General steps
Install git + gitweb
$ sudo apt-get install git-core gitweb
Setup gitweb directories
$ sudo mkdir /var/www/git
$ ... | How to setup Git server on Linux Container in Debian |
1,392,755,257,000 |
If tig is invoked with tig log some/file.txt the log will show all commits affecting that file. Pressing Enter on a line like commit d5dd1d658e5d79701fb9d028479a0fcb26a033fa will open the diff view showing the changes to some/file.txt in that commit but only the changes to that file:
I would like to be able to view t... |
% toggles the file filter in any view and does what you're asking for. You can even switch back and forth between the file's history and the repository's history, or the file-constrained view of a commit and the commit in its entirety.
| How to view entire commit when log is filtered by file in tig |
1,392,755,257,000 |
I'm trying to improve the performance of my fish prompt, and since my prompt includes my current git branch, I'm wondering if there may be a way to make it faster.
Right now I'm using git symbolic-ref HEAD | sed 's/refs\/heads\///', and when I first cd into a git repo, it sometimes hangs for a little while. I'm wonder... |
git symbolic-ref HEAD is as far as I know the fastest method, it basically just opens .git/HEAD and some config files (/etc/gitconfig, $HOME/.gitconfig and .git/config). If you are sure that the delay is caused by the git command it is probably due to some io delay.
If you want a faster method you have to read .git/HE... | What's the fastest (CPU time) way to get my current git branch? |
1,392,755,257,000 |
I have three servers (two ubuntu 16.04, one mac mini) and several macbooks.
One server ubuntu is for gitlab and the other is an internal site server.
The mac mini is running a CI.
Recently the gitlab server was replaced with another gitlab server. (Hardware replaced, same IP address and hostname, new software, new ssh... |
After creating the log for @LazyBadger, I've realised it only fails when run with sudo because it's using a different ssh key.
I've included the root users ssh key on the site servers account on the git server and now it works.
| Git asks for password when using SSH URL, ssh does not |
1,392,755,257,000 |
I am trying to add autocompletion to git commit upon hitting TabTab.
The autocomplete feature I am working on is based on a branch-naming convention. The convention is to append the PivotalTracker Id number to the end of the branch name, so a typical branch would look like foo-bar-baz-1449242.
We can associate the co... |
You could use __git_complete (defined in git-autocompletion.bash) to install your own function, and have your function fall back to the original function. Possibly like this:
function _ptid_git_complete_()
{
local line="${COMP_LINE}" # the entire line that is being completed
# check that the com... | Custom bash autocomplete for git breaks other git autocomplete features |
1,392,755,257,000 |
I installed and run OpenBSD and I wanted to install git but there were no repositories for OpenBSD. What should I do if I want to install some programs with pkg_add?
|
On 6.0 and below, add a mirror to the file /etc/pkg.conf:
installpath = http://ftp.eu.openbsd.org/pub/OpenBSD/5.9/packages/amd64/
On 6.1 and later, use the file /etc/installurl:
https://ftp.eu.openbsd.org/pub/OpenBSD/
| How to enable pkg_add for OpenBSD |
1,392,755,257,000 |
I'm trying to install soundconverter via git. This is what I did in Terminal:
$ sudo apt-get update && sudo apt-get upgrade && sudo apt-get install git
$ git clone https://github.com/kassoulet/soundconverter.git
$ cd soundconverter
$ ./autogen.sh
And here is the output from running /home/USERNAME/soundconverter/aut... |
Researching missing package
As you kind of picked up on this is your issue:
configure.ac:22: warning: macro 'AM_GLIB_GNU_GETTEXT' not found in library
aclocal: installing 'm4/intltool.m4' from '/usr/share/aclocal/intltool.m4'
aclocal: installing 'm4/nls.m4' from '/usr/share/aclocal/nls.m4'
./autogen.sh: 27: ./autogen.... | Warning: macro 'AM_GLIB_GNU_GETTEXT' not found in library |
1,667,989,510,000 |
I have some scripts in a folder that I run often. These scripts are updated frequently. To be more specific, every time we do a deployment on our server, we replace the scripts with updated ones from our git repo.
Do we have to make them executable every time?
|
If you are simply checking out from git, you should be able to set the executable mode flag on the files in git itself.
If you are committing from *Nix (including macOS) then you can usually¹ just chmod +x the file before you git add git commit.
If you are committing from somewhere that doesn't have an executable bit,... | Is it necessary to set the executable bit on scripts checked out from a git repo? |
1,667,989,510,000 |
When I run git clone git://git.gnome.org/tracker, I get:
Cloning into tracker...
git.gnome.org[0: 209.132.180.173]: errno=Connection refused
fatal: unable to connect a socket (Connection refused)
This doesn't happen when I'm not behind a network proxy I'm currently at.
|
Use the http version of git.gnome.org repo and set http_proxy environment variable
http_proxy=http://your.proxy.server:proxy_port
git clone http://git.gnome.org/browse/tracker
you might also need to add the proxy to git config
git config --global http.proxy $http_proxy
| I am failing to clone a git repo when behind a proxy |
1,667,989,510,000 |
A similar question has been asked, but since I am new to Unix the answer was not clear to me due to the context. What I want to do is to pass the output of one command as an argument to another. I am using git for source control and working on three different branches.
Whenever I need to commit I have to check my bra... |
First, you need to massage the git branch output into a useable format
$ git branch
experiment
* master
new feature
$ git branch | awk '/^\* / { print $2 }'
master
Now, you want to use that as an argument:
$ git pull --rebase origin $(git branch | awk '/^\* / { print $2 }')
(or you can use backticks as in psusi... | How can I pass output of one command as an argument to another |
1,667,989,510,000 |
I have two directories: src and projects. I would like to prevent myself from running git ... unless I am specifically inside src or projects. Is this possible?
|
It is difficult to prevent the binary from being run but for the typical situations an easy protection method exists:
You define a shell function that overwrites the name. This will obviously not work in another (also another user's) shell.
You take the binary out of the $PATH and replace it by a wrapper script. This... | Is it possible to restrict certain commands from being run in a directory? |
1,667,989,510,000 |
I can use
git status to see a verbose listing (also git status --verbose) and
git status --short to see a short listing.
How I can I change
git status --short be the default instead of the current default of git status --verbose.
|
See this related stack overflow answer - https://stackoverflow.com/questions/2927672/how-can-i-get-git-status-to-always-use-short-format
It looks like the best option would be making an alias, so you could type git s
to get the short listing instead of git status --short and then just use git status for the --verbose ... | How can I make git status --short be the default |
1,667,989,510,000 |
I want to have an alias that execute a command and then whether it fails or no it execute other commands that depends on the success of each other.
So I have something like that in .gitconfig
getpull = !sh -c 'git remote add $0 $1; git fetch $0 && git checkout -b $2 $0/$2'
With that command I get the following error ... |
I figured it out, it seems something with .gitconfig parser and to solve it we just need to wrap the whole command with double quotes as follow
"!sh -c 'git remote add $0 $1; git fetch $0 && git checkout -b $2 $0/$2'"
| Git alias multi-commands with ; and && |
1,667,989,510,000 |
I often use git diff --name-status BRANCH_NAME to get the list of modified files. Is it possible to colorize the output of that command similar to the output of git status - green for added files, blue for modified, red for deleted and so on.
It's not a duplicate of How to colorize output of git? since I want to color... |
I dont know of any official way to do it, but I wrote this just now and it works for me.
Put the bash script below into a file called: color_git_diff.sh (or whatever you want)
#!/usr/bin/env bash
for i in "$@"
do
if grep -q "^M" <<< "$i"
then
echo -e "\e[33m $i \e[0m"
elif grep -q "^D" <<< "$i"... | Colorize filenames based on status for git diff --name-status |
1,667,989,510,000 |
If I do git status --short, git lists files that are not tracked with two red question marks in front:
I'm trying to store this in a variable and print it with color later. Here's my bash script:
#!/bin/bash
status=$(git status --short)
echo -e "$status"
I thought the -e flag would cause bash to color the output, bu... |
Most programs that produce color will, by default, only produce it when the output is to a terminal, not a pipe or file. Generally, this is a good thing. Often, however, there is an override switch. For example, for ls, one can use --color=always and, as a result, color can be saved in shell variables. For example... | How do I store colored text in a variable and print it with color later? |
1,667,989,510,000 |
I have git repository in /.git, ie root of my filesystem.
When I am in /etc/foo/ and do git status, git tells me that file ../fstab has changed.
When I want to use zsh completion for git command (still in /etc/foo/), ie:
git diff ../fs<TAB>
that works. But when I use absolute path, ie:
git diff /etc/fs<TAB>
then zsh... |
ZSH Completion:
Zsh completion are done with scripts usually located at /usr/share/zsh/5.5/functions/Completion/Unix (may differ depending on the distro) each command completion's script is named _commandName, Zsh include/handle those scripts with the environment variable $fpath similar to the variable $PATH, in this ... | ZSH completion for git does not autocomplete absolute path? |
1,667,989,510,000 |
I am using shell to write a git hook file, to check my commit message before commit. I an a total beginner, this is what I have tried:
My commit-msg hook file is like below:
#!/bin/sh
msg=`head -n 1 $1`
if echo $msg | egrep -qv '(Android-\d{3,4}.{20,})'; then
echo "[Message Format] Your message is not formatted ... |
Your regular expression uses PCRE syntax like \d, but grep -E (that's what your egrep is, but use grep -E instead, egrep is being deprecated) doesn't understand that. Also, you don't need the parentheses there, you aren't actually capturing anything. If you have GNU grep, you can use grep -P instead:
grep -Pqv 'Androi... | How to make if not statement in shell (/bin/sh)? |
1,667,989,510,000 |
I need to build a git server where certain users have a read-write access to the repository and management server running certain scripts using this repository has the read only access to the same repository in the git server:
The setup should be as secure as possible. At the moment I accomplished this with gitolite ... |
The setup you have sounds quite secure. Though hackers will always find a way given enough time. ...Don't sue me if someone hacks you. It might be appropriate for a small setup. For a large team in a large business it might be less appropriate (see "Social Engineering" below).
There are some good points about it a... | secure read-only self hosted git repository for scripts |
1,667,989,510,000 |
I'm on a sort of frankendebian stretch/sid (not the best idea, I know; planning on reinstalling soon).
Tab completion works for git branch names in git repo directories:
:~/project $ git checkout <TAB><TAB>
Display all 200 possibilities? (y or n)
:~/project $ git checkout private-rl_<TAB><TAB>
private-rl_1219_misspel... |
I figured it out, thanks to some gentle prodding from @PatrickMevzek:
The branches I was seeing were actually references to remote branches that had already been deleted. To quote the top answer from the SO thread linked above,
$ git remote prune origin
fixed it for me.
| Tab completion for git branches showing old/outdated entries |
1,667,989,510,000 |
I need an elegant solution to store my dotfiles on GitHub for easy access. I tried to create a dotfiles directory and symlink all the dotfiles into there. Then I tried adding the symlinks to git and committing in that directory, but git saves the links not the contents of the files it points to. Is there a way to do t... |
I have no idea what the best approach is and elegance is certainly in the eye of the beholder, but I use the following for my dotfiles:
A ~/.dotfiles directory that contains all of the dotfiles themselves. These are all managed in a git repo.
A script, also in ~/.dotfiles that creates the required links into my home ... | Elegant Way To Store Dotfiles on GitHub |
1,667,989,510,000 |
I am trying to connect to my repository on gitlab.com.
It used to work on my laptop both when I was at home and when I was at work. I was using ssh and had added the ssh keys to gitlab.
Suddenly some days ago it stopped working from home:
I get:
$ git pull
Connection closed by 54.93.71.23
fatal: Could not read from re... |
Edit your /etc/ssh/ssh_config to:
GSSAPIAuthentication yes
GSSAPIDelegateCredentials no
Ciphers aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc
MACs hmac-md5,hmac-sha1,[email protected],hmac-ripemd160
| ssh connection to gitlab.com fails behind home router, but is fine when at workplace. However, Github and Bitbucket over ssh are fine at home |
1,667,989,510,000 |
I have a Git repository with these branches:
debian
master
pristine-tar
upstream
I do not have an upstream tar ball. Can I create an upstream tarball from the Git repository I have? If so, how?
|
You can use pristine-tar to reconstruct the tarball.
List the available tarballs with
pristine-tar list
then reconstruct the tarball you want with
pristine-tar checkout foo.tar.gz
(replacing foo.tar.gz as appropriate).
| How to create upstream tarball from Git repository of Debian package |
1,667,989,510,000 |
I'm using Arch Linux Linux uplink 4.14.56-1-lts #1 SMP Tue Jul 17 20:11:42 CEST 2018 x86_64 GNU/Linux. I'm trying to solve a problem I'm currently have with GnuPG 2.2.9 (libgcrypt 1.8.3), but I've noticed I have these errors showing up all the time, for any operation I perform with gpg:
gpg: bad data signature from ke... |
I solved this by editing my key and adding the "Signing" usage to the subkey which was encrypt-only.
First edit the key:
> gpg --edit-key "<my@email>"
gpg (GnuPG) 2.2.10; Copyright (C) 2018 Free Software Foundation, Inc.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the ex... | How to solve gpg: bad data signature from key: KEY_ID Wrong key usage (0x19, 0x2) |
1,667,989,510,000 |
I know I can specify external diff command to be used for git diff:
[diff]
external =
But then when I am logged in console (without X) this fails because my visual diff cannot open display (obviously)
How can I tell git to only use visual diff only when logged in GUI/X ?
|
You asked for an answer drawing from credible and/or official
sources so I'm going to cite some official documentation in this
answer.
First, we need to find a way to determine if we're running inside X
session. We could do that for example by checking if $DISPLAY
variable is set. As it's described in man X:
DISPLA... | git: use visual diff (meld) only when in GUI |
1,667,989,510,000 |
I want to keep track of the /etc changes with etckeeper
Unfortunately, the commit messages are the same for all commits
saving uncommitted changes in /etc prior to emerge run
I wish there would be something more descriptive like
apt-get install foo
on debian based systems or
emerge foo
on gentoo based systems when ... |
The changelog message comes from one of the hook scripts of etckeeper. For example the “saving uncommitted changes” message is from /etc/etckeeper/pre-install.d/50uncommitted-changes.
But if you want truly meaningful messages for changes that you made, a computer cannot generate them for you. (Changes resulting from a... | Create meaningful etckeeper commit messages |
1,667,989,510,000 |
I would like to make clean commits with etckeeper. Here is what happens:
1) Check the status of the repository :
git status
On branch master
nothing to commit, working directory clean
2) Modify a configuration file :
vi myfile.conf
3) Add it to the index
git add myfile.conf
4) Make a commit
git commit -m"Add this ... |
Etckeeper sets up a git hook to commit the file containing metadata information whenever metadata changes. This is usually the right thing. If you really want to bypass the commit hook, you can run git commit --no-verify.
The metadata file is sorted by file name. The sorting order depends on the ambient locale. In you... | How to make clean commits with etckeeper? |
1,667,989,510,000 |
I have found a way to upload an SSH key to my GitHub account with command line, but there is small problem.
I am able to do this with following command:
curl -u "user:pass" --data '{"title":"test-key","key":"ssh-rsa Aaa"}'
https://api.github.com/user/keys
But I am using this in Chef to add my nodes' keys to my GitHub... |
The cat command results must be expanded using command substitution.
The syntax for bash is:
curl -u "user:pass" --data '{"title":"test-key","key":"'"$(cat ~/.ssh/id_rsa.pub)"'"}' https://api.github.com/user/keys
You can also use a classic backtick notation:
curl -u "user:pass" --data '{"title":"test-key","key":"'`ca... | upload ssh key on github from command line |
1,667,989,510,000 |
I asked on Superuser about colors for git log in MobaXterm (on Windows), but it turned out that the problem wasn't MobaXterm—it's the lack of a -R flag in busybox's less.
It would help my workflow greatly if I could see colors in the output of git's usual commands—git log, git diff, etc.
My terminal itself is capable ... |
Try installing GNU less on your Windows box. That should fix it.
| Busybox pager with color capability? |
1,667,989,510,000 |
It seems git archive creates a tarball with wrong file modification timestamps, resulting in tar complaining when unpacking:
$ cd repository
$ git archive -o repository.tar.gz master .
$ find /target/dir -type f -delete
$ tar -C /target/dir -xvf repository.tar.gz
some/file.txt
tar: some/file.txt: time stamp 2014-10-29... |
When you give a commit ID or tag ID (or branch name, as you've done here) to git archive, the commit time as recorded in the referenced commit object is used as the modification time of each file in the archive.
It looks like the latest commit on master was at 2014-10-29 13:09:52, which must have been in the future re... | Does `git archive` use the wrong file timestamp? |
1,667,989,510,000 |
I have an alias for git defined as
alias g=git
With this and my zsh and antigen setup, g has the same auto-completion as git.
However, when I replace g with a function to show the git status by default
g() {
if [ "$#" -eq 0 ]; then
git status --short --branch
else
git "$@"
fi
}
this, naturally, doesn't... |
I finally figured it out. It seems to be a bug with antigen. There is also an issue on the antigen Github, which contains a workaround:
For me the way of fixing it was to comment out in the .antigen/init.zsh the following lines:
# autoload -Uz add-zsh-hook; add-zsh-hook precmd _antigen_compinit
# compdef () {}
I kno... | Zsh autocompletion for function based on git, why is compdef not working in .zshrc? |
1,667,989,510,000 |
Creating a git repository for testing.
~ $ mkdir somefolder
~ $ cd somefolder/
~/somefolder $ git init
Initialized empty Git repository in /home/user/somefolder/.git/
~/somefolder $ echo test > xyz
~/somefolder $ mkdir somefolder2
~/somefolder $ echo test2 > ./somefolder2/zzz
~/somefolder $ git add *
~/somef... |
When you do a simple export with HEAD, an internal timestamp is initialized based on the commit's timestamp. When you use more advanced filtering options, the timestamp is set to the current time. To change the behavior, you need to fork/patch git and change the second scenario, eg proof of concept:
diff --git a/archi... | How to create a deterministic tar.gz using git-archive? |
1,667,989,510,000 |
I'm on Ubuntu server 14.04.
I am using apache web server which runs as the www-data. I need to do git clone from a script (a web hook). This script will run with www-data user privilages.
Running git clone as a regular user in the /var/www/html directory I run in to permission problems which is good since I only want ... |
I encountered the same issue, it seems like the environment is preserved when switching users this way. This causes the wrong git config to be loaded, which fails due to permission problems.
In my case I circumvented the problem by using the following command
sudo -u deploydeputy /bin/bash -c "export HOME=/home/deploy... | sudo -u git clone |
1,667,989,510,000 |
Assume I have local workstation with root access and a server without root access. I want to share (mostly configuration) files between these two computers. So I set up a git repository with top-level in my home directory and add these files. So far so good.
Further assume that there exists a file that I need on both... |
From your description, I took it that you wanted to run the shell script on the remote machine. But perhaps it would be more convenient to set up a shell script to run just on your local machine, pushing the package from your local package-directory into your local git repo. Then you could use cron or, neater still, a... | Add file outside git repository [closed] |
1,667,989,510,000 |
There exists a Git repo that is on one server, we want to generate doxygen output for it on a different server. The following command works for me but has the downside of sending a mail everytime the repo is updated because Git uses stderr for progress reporting (a quick search via the almighty oracle suggests they co... |
Relying on the mailing capabilities of crond too much may yield various problems. Depending on your your crond they are perhaps just not flexible enough.
For example, often, as you described, one cannot configure that only an exit status != 0 should trigger the mailing of stdout/stderr. Another issue is that, for exam... | Mail cron output only when Git throws a real error |
1,667,989,510,000 |
I use Vim a lot, and I know how I can start vim in insert mode. So I have an alias named vii in my .bash_aliases file.
On other hand I use Git a lot too, and I have this line in my .gitconfig:
[core]
editor = vi
To write a commit message the vi editor is opened every time and I have to go in insert mode. So I tho... |
Aliases are internal to each of your current shell environments - they are expanded by the currently running shell (bash in your case), so they only have effect on what you execute by typing/pasting in your terminal.
You have at least two options here:
create a wrapper script named vii that will execute vim -c 'start... | place the aliased version of an existing command in /usr/bin/ |
1,667,989,510,000 |
I apt-get install git-core.
I'm trying to install websocketcpp here https://github.com/zaphoyd/websocketpp.
I wget https://github.com/zaphoyd/websocketpp.git.
I have no idea what to do next.
(I've read https://stackoverflow.com/questions/315911/git-for-beginners-the-definitive-practical-guide and http://www.thegeeks... |
What you actually want to do is clone the repository. Here is an example:
git clone https://github.com/zaphoyd/websocketpp.git
| how to install .git file? |
1,667,989,510,000 |
I regularly have to delete a local and remote Git branch. Therefore, I run the following commands:
$ git branch -d feature-branch
$ git push --delete origin feature-branch
Since I mostly execute these two commands in a row, I would like to create an alias for them. Here is my approach:
alias gpdo='git branch -d $1 &... |
When you want aliases to have parameters you can use functions, e.g.
$ gpdo () {
git branch -d "$1" && git push --delete origin "$1"
}
Then you can do gpdo branch_name
This is also useful for multiple commands although they can also be done with an alias with multiple &&s if there are no parameters and no conditi... | How to create an alias for two Git commands that use a parameter? [duplicate] |
1,629,421,485,000 |
I've been arguing about this with my team. In development, we use Windows (CRLF) and on the server we use Linux (LF).
Is there a problem if Linux sees a file with CRLF newlines? Should Git handle such a case via the .gitattributes file?
|
Mostly the linux Kernel itself does not know or care about line endings when you upload files to your server. Though as muru notes CRLF will screw up a shebang.
However there is a convention on in Linux that all lines in text files end in a single LF. Many tools will read the CR and treat it as any other regular char... | Does Linux have a problem with CRLF newlines? |
1,629,421,485,000 |
When using git diff, how can I ignore changes which start with # ?
For normal diff command, I would use something like:
diff <(grep -v '^#' file1) <(grep -v '^#' file2)
But none of the suggested solutions below work!
Is there really no way to see git diff with comments omitted?
UPDATE:
I tries this in my .gitconfig:
... |
It’s possible to do this by filtering all files before diffing them.
First, write a small helper, and call it stripcomments (executable, somewhere on your PATH):
#!/bin/sh -
exec grep -ve '^#' -- "$@"
Then configure a git diff mode using this helper:
git config diff.nocomments.textconv stripcomments
(this will confi... | git diff: ignore comments |
1,629,421,485,000 |
I want to sort the files in a folder by the time they were added to git.
I looked at git ls-files sort by modification time, but this gives me all the files in git by time. I want only the files/folders in that subdirectory.
For eg:
some-super-ls /my/git/repo/some/sub/directory
This should give me output similar to ... |
A variant of this answer to the linked question lists all the files which are tracked, in the current directory, in reverse chronological order based on their last committed change:
git log --pretty='' --name-only | awk '/^[^/]*$/ { if (!seen[$0]++) print }'
| Sort contents of folder by their git time |
1,629,421,485,000 |
I want to find out what files in a certain directory are not managed by Git. This is so I because I use Git for backups, and I want to eventually get all my files personal in there.
What unix tool could accomplish this? Is there a way to use find to do this in a reasonably efficient way?
Example:
I have a folder where... |
find the_starting_dir \( -type d -exec test -d '{}'/.git \; -prune \) -o -print
Not the most portable of find invocations, but works with GNU find.
Find walks the directory tree. The term -prune returns true but stops find from further processing the subtree. So the left hand side of the -o says "if this is a directo... | List files not stored in Git repos |
1,629,421,485,000 |
I wanted to have a git openlast command which would look at the last commit, get a list of added or changed files, filter them to only the text files, and finally open them in an editor.
So far I've done the following:
git show --stat HEAD
read -p "Open in Vim tabs? (Y/n)" -n 1 -r
if [[ -z $REPLY || $REPLY =~ [Yy] ]];... |
You can pipe to xargs and use grep -Il "" to filter out binary files:
git diff --diff-filter=AM --ignore-submodules --name-only HEAD^ | \
xargs grep -Il ""
Example git openfiles command
#!/bin/bash
git show --stat HEAD
files=($(git diff --diff-filter=AM --ignore-submodules --name-only HEAD^ | xargs grep -Il ""))
re... | How do I filter a list of files for text only files? |
1,629,421,485,000 |
I have cloned a xorg git repository:
git clone git://anonscm.debian.org/pkg-xorg/driver/xserver-xorg-video-intel
and I need to extract all files as they looked after commit 45c09bfe58c37bbf7965af25bdd4fa5c37c0908f
I know how to extract one file of a specified version, i.e.
git show 45c09bfe58c37bbf7965af25bdd4fa5c37c... |
To check out a specific commit:
git checkout 45c09bfe58c37bbf7965af25bdd4fa5c37c0908f
This will report an error if it would need to overwrite files that are not committed. To unconditionally overwrite file, pass the -f option.
To extract a commit without affecting the working copy:
git archive 45c09bfe58c37bbf7965af2... | extract snapshot of git repository at a given time |
1,629,421,485,000 |
For one specific user I want to be able to restart Apache. This user does have sudo privileges and I could run sudo /etc/init.d/apache2 reload, but I want to include this restart script in a git post-receive hook. So this would prompt for the password and fail. So the question is: what is the proper way to allow this ... |
You should consider using sudo with the NOPASSWD config.
See man 5 sudoers
Ex:
Host_Alias LOCAL=192.168.0.1
user_foobar LOCAL=NOPASSWD: /etc/init.d/apache2
| How do I restart apache as non-root (using a git-hook)? |
1,629,421,485,000 |
I have a development machine that use runs on CentOs.
Whenever i pull from git using git pull i get "permission denied" issue/error.
Git apparently doesn't have the permission to overwrite the files needed when i do a pull. Thus after every time i have to sudo git pull to get it to work.
I would rather not do a sudo... |
Git itself doesn't have any permissions. It relies entirely on the operating system level permissions.
If you're the only person using that git repo, then do this:
cd dir_of_repo
sudo chown -R ${LOGNAME} $(pwd)
sudo chmod -R u+rwX $(pwd)
If you're sharing this with other people, then you probably need to read Underst... | Permissions issue with git |
1,629,421,485,000 |
I am trying to implement this helper bash function:
ores_simple_push(){(
set -eo pipefail
git add .
git add -A
args=("$@")
if [[ ${#args[@]} -lt 1 ]]; then
args+=('squash-this-commit')
fi
git commit -am "'${args[@]}'" || { echo; }
git push
)}
with: git commit -am 'some stuff here', I reall... |
In Korn/POSIX-like shells, while "$@" expands to all the positional parameters, separated (in list contexts), "$*" expands to the concatenation of the positional parameters with the first character (byte with some shells) of $IFS¹ or with SPC if $IFS is unset or with nothing if $IFS is set to the empty string.
And in ... | How to concatenate "$@" or array to one string [duplicate] |
1,629,421,485,000 |
I have a feature branch in git that needs to be up to date with the master branch at all times. Is there any way to automatize this in git? I basically want on every commit in master branch a merge into feature branch.
|
You could create a server-side update hook to do this merge whenever someone pushes new commits to master. See the relevant section of Pro Git for an overview.
Now, I would submit to you that the presence of this requirement indicates a problem with your development workflow, since the whole point of a "feature branc... | Is there any git option to automatically merge commits from master branch into a feature branch? |
1,629,421,485,000 |
I want to make a git diff alias that only shows the changed lines (coloured).
[alias]
mdiff = diff --color | grep --color=never $'^\e\[3[12]m'
This doesn't work, as apparently pipes cannot be used in git aliases, but this answer shows a workaround:
[alias]
mdiff = ! git diff --color | grep --color=never $'^\e... |
A git alias without ! is run by Git itself. If the alias contains a | character, that's just a | character. No shell is involved, so | doesn't mean a pipe.
A git alias starting with ! is run by a shell. Git runs what follows the ! in a shell (after doing some quote parsing), and passes the arguments at the end. Your s... | How can I make this git alias with quotes work? |
1,629,421,485,000 |
I'm currently writing a bash script to remind me to rebase git repos when the local master branch is found to be behind origin/master.
So far I have come up with the following, but $? always returns 1 (I suspect this is because even an empty diff still loads less.
#!/bin/bash
REPO_PATH=$1
cd $REPO_PATH
# flow once i... |
You should use git-merge-base’s --is-ancestor test:
if git merge-base --is-ancestor origin/master master; then
echo Empty
else
echo "Don't forget to rebase!"
fi
| Check via shell-script if git repository's master branch is behind origin |
1,629,421,485,000 |
The Issue:
When I type:
dpkg-query -Wf '${Package;-40}${Priority}\n' | sort -b -k2,2 -k1,1
I get a list of all installed packages on my machine, example:
...
raspberrypi-artwork extra
raspberrypi-bootloader extra
raspberrypi-ui-mods extra
raspi-config ... |
You can use the following command to purge all optional and extra packages:
sudo apt-get --simulate purge $(dpkg-query -Wf '${Package;-40}${Priority}\n' | awk '$2 ~ /optional|extra/ { print $1 }')
The --simulate flag lets you see what will be removed without actually removing everything. Remove the flag to actually un... | write error: No space left on device. Removing 'extra' packages. Attempting recovery |
1,629,421,485,000 |
I have my git repository on a linux located on the company server. I ssh into my linux machine and edit files there.
Problem
This method is great until I have a good connection to the server. in case of slow connection or even not having a connection I can't access my work and I am not able to do the job.
Potential So... |
I'm not entirely sure from the way the question was phrased, but it sounds to me like you might be experiencing some trouble moving from a non distributed version control system (svn, csv, etc.) to a distributed one like git.
As it turns out, you get the functionality you want for free in Git! Simply clone your git re... | Sync local files to remote git repository |
1,629,421,485,000 |
I created a bare git repository and pushed to as root. Then I ran su myuser and ran the following commands:
$ whoami
myuser
$ mkdir t
$ cd t
$ git clone ssh://[email protected]:1234/git3
Cloning into git3...
[email protected]'s password:
fatal: '/git3' does not appear to be a git repository
fatal: The remote end hung... |
erm, don't you need:
$ git clone ssh://[email protected]:1234/home/myuser/git3
??
| Unable to git clone over ssh |
1,629,421,485,000 |
I have set up diff-highlight as pager / highlighter for git.
[pager]
log = diff-highlight | less
show = diff-highlight | less
diff = diff-highlight | less
That works perfectly.
But how can I use diff-highlight for normal diff ?
|
You can define a function:
diff() { /usr/bin/diff "$@" | diff-highlight }
diff-highlight processes unified diffs (diff -u) but piping other formats appears to work — it passes them through unchanged.
To approximate the behaviour you get with git diff, you’d need colordiff too:
diff() { colordiff -u "$@" | diff-highli... | use 'diff-highlight' for diff |
1,629,421,485,000 |
I have a virtualbox VM with arch Linux running on my windows PC (which I unfortunately have to use for work). I use this to work on my windows PC with a Linux environment as an alternative to Cygwin.
I have set up a Virtualbox shared folder which shares my C:\ drive with my Linux VM but I seem to be unable to change t... |
This will not work as it unlikely that your hosts mapped in filesystem (i.e. Windows C: drive, so most likely NTFS) supports the full range of permission bits that Linux git expects.
In a similar situation I have exported a Linux directory via Samba and used that from Windows and Linux without problems. This however h... | In a Virtualbox VM how do I set the filesystem permissions? |
1,629,421,485,000 |
I tried setting up git-shell on our CentOS (6.4) system (after getting this working correctly on Ubuntu 13.10, maybe cross platform hot mess?)
my /etc/passwd shows
git:x:500:500:Web Archive VCS:/home/git:/usr/bin/git-shell
and my shell commands are in /home/git/git-shell-commands
[root@domain git]# cd /home/git/git-s... |
As it turns out, this feature has been introduced in git 1.7.4.
git --version gave me 1.7.1 on a base CentOS 6.4 install so
that was the beginning of the issue =/
If you experience this problem, check your git version. Here's
is an updater script that I wrote to aid you in your troubles.
#!/bin/bash
# Git updater fo... | Granting access to a restricted git shell |
1,629,421,485,000 |
I created git bare repository in my home directory like ~/git-repos/foo.git.
To add a remote repository I typed like git remote add origin ssh://username@hostname:10022~/git-repo/foo.git.
But it fails with error ssh: Could not resolve hostname hostname:10022~: Name or service not known.
If I replace ~ to /home/usernam... |
You need a / to indicate where the host spec ends and the path begins:
git remote add origin ssh://username@hostname:10022/~/git-repo/foo.git
| `git remote add` to home dir by `~` expression |
1,629,421,485,000 |
I have a bash script, called cgit, that acts as git for one specific git repo (located at /.git):
#!/bin/bash
cd /;
sudo git $@ > /dev/stdout
I use it to keep track of imporant system files:
cgit add /etc/rc.conf
The trouble is when I try to add content relative to the directory I'm in, for example:
cd /home/user
... |
I'd update your cgit script to use --git-dir.
From the man pages:
--git-dir=<path>
Set the path to the repository. This can also be controlled by
setting the GIT_DIR environment variable. It can be an absolute
path or relative path to current working directory.
So it would become:
#!/bin/bash
... | Specifying which git repo to use |
1,629,421,485,000 |
I am using filter to remove comments before committing config files in git:
$ cat .git/config
[filter "stripcomments"]
clean = "stripcomments"
$ cat .git/info/attributes
/etc/* filter=stripcomments
I also have shell prompt which changes color if there are any uncommited files. This is the relevant part in my .zshrc... |
git status works as expected if you change comments without changing file size e.g. change one character, or have two one-line comments and switch them, anything that doesn't change the total length of the file nor the filtered result.
For modified (mtime) files of the same size, git status reads their contents, runs ... | git: inconsistent behavior when using filter to strip comments |
1,629,421,485,000 |
I have files in my git directory that have permission 600.
When I used git-pull in my computer and git-push in another computer, the permission changes to 664.
Is there a way to preserve permissions(600) after git-pull?
Thanks
|
As mentioned by @Kusalananda, git normally only tracks execute permissions. In order to save more permissions information, you would need to implement a pre-commit hook that would gather up the permissions info and store it separately, and another hook to restore permissions on pull.
etckeeper is basically a collectio... | Permission changed from 600 to 664 after git push-pull |
1,629,421,485,000 |
I am trying to write a bash-script to update a remote git repo.
The script looks something like:
#!/bin/bash
ssh [email protected] 'cd /home/h/usr/praktikum | git pull | sbatch run.sh'
However, the cd command has no effect!
fatal: not a git repository (or any parent up to mount point /home)
How can I get into the... |
This works to me:
ssh [email protected] -t "cd /home/h/usr/praktikum && git pull && sbatch run.sh; bash --login"
For not will leave you in a remote shell:
ssh [email protected] -t "cd /home/h/usr/praktikum && git pull && sbatch run.sh"
| How can I combine the ssh and cd commands? |
1,629,421,485,000 |
A lot of repositories on Github have an "automatic" installer like the one posted below. I always wonder how to find out which binaries will get installed but I can not figure it out from the script.
This is an example from libbitcoin-explorer.
|
Most "installers" (be it a custom one like the one that you link to, or a Makefile that is created from a GNU autotools configure script, or a CMake or Meson build specification etc.) allows you to set an installation prefix. The one you point to, for example, seems to have a --prefix option. The --prefix option is ... | How to find out which files get installed with make? |
1,629,421,485,000 |
I have checked out linux kernel git repository
git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
I know how to use git log, git show and similar commands to see changes/commits in the main kernel tree. For my particular purpose, I am however only interested in changes of the kernel tree 3.18.... |
I would rather clone this git. And then do git diff --stat
$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git`
$ cd linux-stable/
$ git diff --stat v3.18.6 v3.18.7
| git: show which files have changed between kernel 3.18.6 and 3.18.7 |
1,629,421,485,000 |
I want to automate the installation of etckeeper on OpenSuse 12.3.
My first issue is that etckeeper doesn't seem to be available in the standard OpenSuse repos.
zypper search etckeeper
Loading repository data...
Reading installed packages...
No packages found.
The second issue I anticipate is that when I use etckeep... |
OK, here's an answer, but it is not ideal. I was hoping to find an official OpenSuse package from one of the repos. But until someone suggests a better alternative, here's what I came up with:
find the package:
http://software.opensuse.org/package/etckeeper
download it:
wget http://download.opensuse.org/repositories/... | etckeeper for opensuse - bash script install and configure |
1,629,421,485,000 |
I am trying to install git using my yum command
Following is the error log
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
Updating certificate-based repositories.
Unable to read consumer identity
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Packag... |
Try disabling the RPMForge repo
Do the command as follows:
$ sudo yum --disablerepo=rpmforge install git
The repositories EPEL and RPMForge don't get along that well.
Mixing EPEL6 repos with EPEL5?
If the above doesn't resolve the issue then it would appear that you're mixing EPEL6 repositories with your CentOS 5 ins... | Installing Git Unit |
1,629,421,485,000 |
I want to update my git version to the latest (2.38.1).
This is my version:
git --version
git version 2.37.1 (Apple Git-137.1)
I am following the guide "Git via Git" and so I type:
git clone https://github.com/git/git
But if I re-type:
git --version
git version 2.37.1 (Apple Git-137.1)
As you can see the version se... |
Merely checking out a source code repository will not update the installed software on your system. You would have to build and install the software, which is a process described in the project's documentation (see, e.g., the INSTALL file).
However, unless you want the most bleeding edge unstable development version o... | Git does not update while doing git clone |
1,629,421,485,000 |
I am trying to use git salt ssh access (which runs with root). The error is always:
Permission denied (publickey).
I managed to reproduce the problem, simulating what salt may be doing, by running an ssh command on the root user, and then the same command with sudo (still on the root account), getting the same error... |
Somehow it was related to the id_rsa.pub file. For the root user, it didn't make a problem, but for sudo through root, it apparently does not work.
Perhaps it is a particular case with root that blocks this or perhaps it needs another special permission, other than the recommended ones or group configuration.
The "sol... | Problem with sudoing ssh - `sudo ssh ...` fails |
1,629,421,485,000 |
I'm trying to set up a Raspberry Pi to check a repo on startup and then fire up a node script with forever.
I got the second part working, but I tried a dozen git commands with no success.
Here is my crontab that I access like so:
crontab -u pi -e
@reboot /bin/sh /home/pi/code/script.sh
Now my script has -rwxr-xr-x ... |
After getting help to debug and trying out Phlogi's solution without success, I decided to go back to the original crontab and just add code to wait for the network interface to be ready. Here is what the script looks like now:
#!/bin/sh
while ! ping -c 1 -W 1 bitbucket.org; do
echo "Waiting for bitbucket - netwo... | Crontab shell script git pull and forever start |
1,629,421,485,000 |
I know this has been asked a lot but I did not manage to get any solution to solve my problem.
My coworker assigned me on a new project. The application is hosted on test Debian server with git installed.
First I have created my branch :
git checkout -b mybranch
Then I have done small modifications to some files.
Whe... |
Turn out it was indeed a ram problem. 268mo was not enough for git to function properly.
I solved the problem by adding 1Go of swap to the server:
$ sudo fallocate -l 1G /swapfile
$ sudo chmod 600 /swapfile
$ sudo mkswap /swapfile
$ sudo swapon /swapfile
| git Fatal: Out of memory, malloc failed on branch push |
1,629,421,485,000 |
How do I extract the names from the gitolite info command output, for further piping into a script?
I'm writing a migration script to migrate all my repositories from gitolite to a Gitlab server. Thus, I want to get all the repository names from gitolite and use those in Gitlab. Below is the example output I'm trying ... |
Based on the input you show in your question, this should work:
$ grep -oP '^[ @]*R.* \K.*' gitolite-info-output
SecureBrowse
anu-wsd
entrans
git-notes
gitolite
gitolite-admin
indic_web_input
proxy
testing
vic
This is using GNU grep's -P switch to enable Perl Compatible Regular Expressions which give us \K : "Exclude... | Find repository names from gitolite info output |
1,629,421,485,000 |
I'm trying to get some nice output out of git:
FORMAT='%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'
LOG_PARAMS="--color --pretty=format:$FORMAT --abbrev-commit --no-walk"
function gch() {
git log $LOG_PARAMS $(commits)
}
(where commits is a function that collects relevant commits).... |
You have just suffered from word splitting - Use More Quotes™ and use arrays if you want to send multiple parameters to a command:
LOG_PARAMS=("--color" "--pretty=format:$FORMAT" "--abbrev-commit" "--no-walk")
...
git log "${LOG_PARAMS[@]}" "$(commits)"
This works for me without the "$(commits)" part, which I gue... | Bash script with quotes and spaces |
1,629,421,485,000 |
I'm wondering how exactly GitHub does what they do as far as hosting Git repositories goes. For example, I'm assuming that they manage repository push permissions based on values in some SQL table somewhere, something like:
create table user (id int primary key auto_increment,
username varchar(255),
... |
All of them rely on ssh to authenticate the user, then something else for authorization. Gitosis and Gitolite both use a config file; Gitorious uses (I think) a database (although, it may be generating a config file anytime project permissions change; not sure).
| Hosting Git Repositories as per GitHub [closed] |
1,629,421,485,000 |
The title seems a bit weird, so a bit of background:
I got a couples of local git repos, and found myself wanting to make a backup. Two method came to mind, git bundle and tar (aware there many other but i wanted something "simple" and that would make repo packed in a "single file")
Using Tar
The command i tried was... |
Seems like tar work as expected if i move the tar before extracting it:
mv gitrepo.tar otherdir/
cd otherdir ; tar xvf gitrepo.tar
As an alternative, zip seems to work fine without moving the archive first:
zip -Zs -r -FS gitrepo.zip gitrepo/
The above does zip without compression.
| How to backup local git repo the right way in a single file? |
1,472,032,051,000 |
I'm running a Mac and use iTerm with ZSH as my shell.
Currently I can command-click (⌘+click) on links or directories in my iTerm window, and that directory or web link will open.
Is there a way (plugin, config tweak, etc) to make it so I can do a git log, and then command-click on a git commit ID, and be taken direct... |
Sadly, no(t practically). There's no way to know if a given hash is even a Git commit ID, and if it is, whether it's on GitHub, a local git repo, or any of the hozillion other git repository hosting sites out there.
| command-click git commit ID in Terminal, and be taken to that commit in github? |
1,472,032,051,000 |
I am experiencing severe slowdown in Git checkouts from VM. I've been told that one of the reasons may be SSH compression (either enabled or disabled). How to check that is the state of compression during checkouts?
The checkout is made by Ansible job if that matters.
|
Check your .ssh/config file and/or create a ssh wrapper script:
echo '#!/bin/sh\nssh -v -v $*' > custom_ssh
chmod +x custom_ssh
GIT_SSH="./custom_ssh" git clone [...]
and check the debug output of ssh.
| How to check if SSH compression is enabled? |
1,472,032,051,000 |
I have a Push command, that runs this script:
FindGits |
{
while read gitFolder; do
parent=$(dirname $gitFolder);
if [[ `git -C $parent status --porcelain` ]]; then
echo;
(
echo $parent;
git -C $parent status --porcelain
git -C... |
If you are using ssh authentication for working with git repositories (and make pull,push, etc.) you have to config every repository to use ssh authentication instead of https, otherwise the git command will keep asking for your user and password.
For changing the repository authentication to ssh you can use something... | Why git asks for username when ran inside a script? |
1,472,032,051,000 |
I have set up a post-recieve hook for Github. It will issue a POST-Request to an Apache cgi-script, which then is supposed to download the changes to the repo into the locally cloned bare repository. The script is running fine when I add a VARIABLE=$(cat -), yet I get a curl error when I try to issue a post request an... |
I imagine that apache is doing something equivalent to: reading all the request from the client, including the POST data, and writing it via a pipe (say) to the cgi process. It also reads the reply from the cgi and sends it to the client. It does a loop with select() continuing these reads and writes simultaneously.
W... | Not consuming STDIN causes curl error |
1,472,032,051,000 |
I recently initiated a git repo and forgot to add a .gitignore file. After my initial commit, my repo has many subdirectories and many files that should have been ignored. Is there an efficient way to add a .gitignore and then push the repo without the files meant to be ignored to a tool like GitLab or GitHub?
|
If you don’t mind deleting all the ignored files in the working directory, the following will stage all committed-but-ignored files for deletion:
find . -print0 | git check-ignore -z --stdin --no-index | xargs -0 git rm -f -r --cached --ignore-unmatch --
(assuming GNU find and a recent enough git for git check-ignore... | Stripping a git repo of all committed files that should have been ignored |
1,472,032,051,000 |
I have a branch in a git repo. How can I find the single commit in the repo that most closely matches the branch? Like if I run a diff, between this branch and every other commit in the repo, I want to find the commit that produces the least amount of diff lines.
|
This was my solution:
#!/bin/sh
start_date="2012-03-01"
end_date="2012-06-01"
needle_ref="aaa"
echo "" > /tmp/script.out;
shas=$(git log --oneline --all --after="$start_date" --until="$end_date" | cut -d' ' -f 1)
for sha in $shas
do
wc=$(git diff --name-only "$needle_ref" "$sha" | wc -l)
wc=$(printf %04d $wc... | How can I find the git commit in a repo that is more similar to a specified branch? |
1,472,032,051,000 |
Is there some way to stage individual lines of a file which has just been changed to include newline at EOF? I tried add -p, but it wouldn't split the relevant hunk into small enough parts, and it's well known that git-gui throws a "corrupt patch" error when dealing with files without a newline at the end. The relevan... |
Maybe this solution can work for you too:
https://stackoverflow.com/questions/6276752/can-i-split-already-splitted-hunk-with-git
Edit the hunk and add \ No newline at end of file at the end of the + lines.
Edit:
Now that I understood your requirement: Use git add -p to get into interactive mode, delete the +/- lines y... | How to stage part of hunk with added newline at EOF? |
1,472,032,051,000 |
I am running Ubuntu 16.04. Recently I often find one or two "git status -z -u" process that each takes more than 5GB of memory. So I try to figure out what's going wrong. pstree gives me some output like this:
systemd──lightdm──lightdm──upstart──2*[git]
Apparently upstart started these git processes. So I try to list... |
@DopeGhoti is correct in the comments. In my case, it turns out to be the problem of Visual Studio Code working on dictionary from mounted network locations. After disable the git in Visual Studio Code, the problem is gone.
| High memory usage from "git status -z -u"? |
1,472,032,051,000 |
I can't seem to add an alias for git add **/
I think those two asterisks is causing an issue, or it could be that forward slash. How do I solve this?
So far I have tried
alias ga='git add **/'
When I run the above alias in my terminal, I issue this command ga somename.java which would be an equivalent if alias was n... |
ga somename.java is short for git add **/ somename.java. The first argument to the alias is not concatenated to the last word inside the alias. You can think of it this way: the space that you type after ga is not removed.
To do anything more complex than give a command an alternate name or pass arguments to a command... | How to add an alias for 'git add **/' |
1,472,032,051,000 |
I am trying to find all directories in a folder recursively while exclude all git submodules by excluding all path containing .git file. How could I do it?
Explanation:
.git file exists at the root of every submodules folder. This submodule folder could be included anywhere.
Test Case
$ mkdir Test
$ cd Test
$ mkdi... |
find actions are also tests, so you can add tests using -exec:
find . \( -exec [ -f {}/.git ] \; -prune \) -o \( -name .git -prune \) -o -print
This applies three sets of actions:
-exec [ -f {}/.git ] \; -prune prunes directories containing a file named .git
-name .git -prune prunes directories named .git (so the co... | Find exclude path containing specific files |
1,472,032,051,000 |
I have been browsing Git Basics - Viewing the Commit History as well as Git Tools - Searching and while most of the ways seem straight-forward I have been trying to figure out if there was a way to figure out the author who has done the most commits or/and the committers who has done most of the commits in a porject... |
git log --pretty=format:%aN | sort | uniq -c | sort -n
git log --pretty=format:%aN outputs just the author name for every commit. sort collects all the repeated names together, then uniq -c turns each run of equal lines into the number of repetitions and the value, before sorting numerically. You can take the last li... | How to find which author and committer has done more commits to a project using git log? |
1,472,032,051,000 |
I'm interested in accurately removing a git repository in a reasonable time.
But it takes quite a while to do so. Here, I have a small test repo where the .git folder is < 5MiB.
$ du -ac ~/tmp/.git | tail -1
4772 total
$ find ~/tmp/.git -type f | wc -l
991
Using shred's default options, this takes quite long. In t... |
Forget about shred, it spends a lot of time doing useless things and misses the essential.
shred wipes files by making multiple passes of overwriting files with random data (a “Gutmann wipe”), because with the disk technologies of 20–30 years ago and some expensive laboratory equipment, it was possible (at least in th... | How can I shred a git repository, reasonably fast? |
1,472,032,051,000 |
I was installing git-all in my system and did it without reading the confirmation of packages that it would be messing with, and when I returned my graphical interface was simply gone...
Don't know why it removed those gnome packages but it did, so what happened and how can I overcome this?
Also is it necessary for me... |
If you just want to use the git tool, you do not need to install git-all. You can look the description of the packages by running apt-cache show git and apt-cache show git-all, as well as the packages they install, read the materials they link to, and then decide.
The package git-all recommends alternatively git-daemo... | So, I tried t install git-all and it removed various gnome packages in my system, I don't really know the reason. How can I overcome this? |
1,472,032,051,000 |
I have a Git repo that is authenticated with an SSH key - the key is not the standard id_rsa.
I can run:
eval $(ssh-agent -s)
ssh-add /home/forge/.ssh/otherkey
Then
git pull origin master
This is working.
The server needs to do a git pull on boot.
So I have code in rc.local that pull the repo it's working only when... |
You can add ssh key file using ssh config.
Here is default for all users /etc/ssh/ssh_config
Here is for current user ~/.ssh/config
Example of current user ssh config per host:
## Home nas server ##
Host nas01
HostName 192.168.1.100
User root
IdentityFile ~/.ssh/nas01.key
## Login AWS Cloud ##
Host aw... | Add an SSH key on boot |
1,472,032,051,000 |
I've installed git and tk, and I'm able to run git citool to display the Git GUI and create a single commit, after which the application exits. Unfortunately the git gui command itself says
git: 'gui' is not a git command. See 'git --help'
and so I'm stuck. How do I
enable git gui as a command to
show the Git GUI u... |
Installing git and tk won't work on NixOS because git won't be able to see tk. Unlike most Linux distributions, NixOS doesn't have a global location (such as /usr/lib) for libraries. Instead, executables are modified in such a way that they are able to locate the libraries they need in the Nix store (/nix/store).
To ... | How to enable `git gui` in NixOS? |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.