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): setenv PAGER less setenv LESS R To select GNU less as your pager and tell less to pass text formatting escape sequences through. If you don't set the LESS variable, git sets it to FRX (so includes R already, but also F and X which you may want as well). So you may want to omit that part if you prefer the FRX behaviour (see less man page for details), or unset LESS it if you had it set to a different value, or set it yourself to FRX. That PAGER environment variable is used by a few things (like man) beside git. If you want to change your pager only for git, you can set the GIT_PAGER environment variable instead. Alternatively, you can do: git config --global core.pager 'less -FRX' You can tell git to not use colour when using a pager with: git config --global color.pager false See env PAGER=less git config --help for details.
"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/ftplugin/gitcommit.vim), because I rely on $VISUAL rather than configuring editors for everything separately. This almost works: call feedkeys('ggA', 'int') However, when running echo 'some text' >/tmp/COMMIT_EDITMSG && vim -Nu NONE --cmd 'filetype plugin on' /tmp/COMMIT_EDITMSG the cursor is on the status line until I press something: 1 | startinsert! works for echo 'some text' >/tmp/COMMIT_EDITMSG && vim -Nu NONE --cmd 'filetype plugin on' /tmp/COMMIT_EDITMSG, but when running git commit -t /tmp/COMMIT_EDITMSG it breaks completely - the commit message is not shown and the commit template is shown below the status line: After pressing right arrow the commit message and cursor shows up, and the editor is in insert mode, but the cursor is at the second character rather than at the end of line: Do I need to add something to the configuration to tell Vim to show the actual contents of the buffer?
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 the line is printed.
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 a GUI is a most convenient way to manage conflict for example. As I am using l low powered device, I am also looking for a ligweight client of course Best regards.
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 it doesn’t quite count as lightweight!
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 the HEAD of the branch I am working in (not master).
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: git checkout foo git reset --hard c70611 If this is considered to be a good state to push to foo's upstream then just git push <remote-name> foo. There is a more direct way to force foo to c70611 without checking it out to be the current branch. Namely, you can rewrite what foo points to using the git update-ref command. Before doing any of the above, I would pause and try to see how I had ended up in a detached state without noticing. Perhaps it was an unfinished rebase or whatever. Step one is to review the last few entries in the git reflog to help jog your memory.
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 found. $which git git: Command not found. $ls -l /usr/local/bin/git -rwxr-xr-x 112 root users 5851488 Mar 15 20:07 /usr/local/bin/git $whereis git git: /usr/local/bin/git $echo $PATH /usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin EDIT: It works now but do not know why I disconnected the telnet connection and logged in again few minutes back and find that the git command works. I am not sure what caused it to start working. This is confusing.
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 command is not found. Many shells keep information about the location of commands in the search path in a cache. I don't know if any version of csh caches negative lookups, but it seems that yours does. Run the command rehash to refresh the cache. When you start a new shell instance, it has a fresh cache and so doesn't remember that git was not present earlier.
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 running debian with that same directory mounted, and in the docker image, the opposite behavior occurs: $ git diff-index --quiet HEAD ; echo $? 0 # At this point, `git status` was invoked outside the docker image $ git --version git version 2.20.1 $ git diff-index --quiet HEAD ; echo $? 1 To be clear, the sequence of commands executed here is: git diff-index on the docker image (returns 0), git diff-index on the host (returns 1), git status on the host, git diff-index on the host (returns 0), git diff-index on the docker image (returns 1). Basically, if I run git-status in one environment, git diff-index will succeed (return 0) in that environment and fail in the other. Any thoughts about what is going on? This isn't a big deal, and I have a suspicion that the case insensitivity of the file system is to blame, but I'd love a solid explanation.
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 as git status and git diff update the cache as needed. Lower-level commands like git diff-index and git diff-files are designed to return quick, but approximate results. They don't update the cache. They return 0 if they're sure that the things they're comparing are identical, but when they return 1, all it means is “I'm not aware that the things are identical”. If the cache entries are stale, it's possible that the things are identical but git diff-xxx doesn't know. I don't know exactly how the cache works. In your first experiment, it seems that the first call to git diff-index noticed that the cache entry was stale, and so returned 1 for “I don't know”. Then git status updated the cache, and the second call to git diff-index saw valid cache entries and was able to conclude that the files are identical. In your second experiment, running git status outside the Docker container seems to have created cache entries that git diff-index inside the container considered to be stale, so the second call to git diff-index returned 1 for “I don't know”. My solution was to forget about low-level commands and stick to git diff --quiet.
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_handler function (if it's defined). This function receives the command and the command's arguments as its arguments. command_not_found_handler () { git "$@" } If you want to do some fancier filtering, the command is in $1 and its arguments can be referred to as "$@[2,$#]". command_not_found_handler () { if …; then git "$1" "$@[2,$#]" fi }
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 but not in some older revision, which is the simplest form of revision range OLD..NEW. git log v4.4..v4.9.273 The git log command has many options to control the output format, for example --oneline to have just one line per commit, --name-status if you want to know what files each commit modifies, --decorate to show tag and branch names in addition to commit IDs, --format=%H to only list commit IDs (useful to then iterate over the commits programmatically), etc.
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 \ 'cd {}; git fetch --all --quiet' I don't really care what happens if the fetch fails -- it might succeed the next time. Perhaps error output could be logged. My questions are: What if the background process fetches into a Git repository while I'm committing to it? Can you recommend other switches to parallel to make this really fail-safe?
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 fetch --all --verbose" \ >> ~/log/git-fetch.log 2>&1 (but in one line).
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 extracted the file git-2.17.1.zip on /home/myusername/temp/ Changed to the extracted file's directory, in this case /home/myusername/temp/git-2.17.1/ As a super user, installed all supposedly needed dependencies, using: a) yum install docbook2X-0.8.8-17.el7.x86_64.rpm (after having downloaded this package) b) yum install dh-autoreconf curl-devel expat-devel gettext-devel openssl-devel perl-devel zlib-devel asciidoc xmlto gengetopt autoconf libcurl-devel gcc kernel-headers debhelper intltool perl-Git po-debconf Created a symlink as instructed on git-scm web site, using: a) ln -s /usr/bin/db2x_docbook2texi /usr/bin/docbook2x-texi As a normal user, ran the following: ./configure CFLAGS='-I/usr/local/openssl/include' LDFLAGS='-L/usr/local/openssl/lib' --prefix=/usr/local/git --with-openssl=/usr/local/bin/openssl make all doc info And again, as a super user, ran the following: make install install-doc install-html install-info The problem arises on last step, outputting the following: install -m 644 git.info gitman.info /usr/local/git/share/info if test -r /usr/local/git/share/info/dir; then \ install-info --info-dir=/usr/local/git/share/info git.info ;\ install-info --info-dir=/usr/local/git/share/info gitman.info ;\ else \ echo "No directory found in /usr/local/git/share/info" >&2 ; \ fi No directory found in /usr/local/git/share/info mak e[1]: Leaving directory `/home/myusername/temp/git-2.17.1/Documentation' I successfully upgraded openssl version to the latest available today (openssl 1.1.0h).
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 \ $(INSTALL_INFO) --info-dir=$(DESTDIR)$(infodir) git.info ;\ $(INSTALL_INFO) --info-dir=$(DESTDIR)$(infodir) gitman.info ;\ else \ echo "No directory found in $(DESTDIR)$(infodir)" >&2 ; \ fi Program named install correctly creates info-pages in /usr/local/git/share/info/, you can check it: $ ls -lh /usr/local/git/share/info/ total 2.3M -rw-r--r-- 1 root root 218K Jun 13 21:46 git.info -rw-r--r-- 1 root root 2.1M Jun 13 21:46 gitman.info The install-info target was introduced in commit 4739809c and says: If the info target directory does not already contain a "dir" file, no directory entry is created. A file named dir is a part of GNU texinfo but it's not required. Also notice that unless you have /usr/local/git/bin/ in your $PATH you cannot start git by simply typing git after installing it the way you did, you have to do this instead: $ /usr/local/git/bin/git --version git version 2.17.1
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+https://github.com/facebook/proxygen#7e37f926d922b55c85537057b57188dea9694c32" Result: -> Creating working copy of proxygen git repo... remote: Counting objects: 6, done. remote: Compressing objects: 100% (6/6), done. remote: Total 6 (delta 4), reused 0 (delta 0) Unpacking objects: 100% (6/6), done. From /tmp/yaourt-tmp-german/aur-hhvm-git/proxygen 7e2a49c..3395064 master -> origin/master ==> ERROR: Unrecognized reference: 7e37f926d922b55c85537057b57188dea9694c32
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 the source in the form source=('directory::url#fragment'). Currently makepkg supports the Bazaar, Git, Subversion, and Mercurial version control systems. For other version control systems, manual cloning of upstream repositories must be done in the prepare() function. The source URL is divided into three components: directory (optional) Specifies an alternate directory name for makepkg to download the VCS source into. url The URL to the VCS repository. This must include the VCS in the URL protocol for makepkg to recognize this as a VCS source. If the protocol does not include the VCS name, it can be added by prefixing the URL with vcs+. For example, using a Git repository over HTTPS would have a source URL in the form: git+https://.... fragment (optional) Allows specifying a revision number or branch for makepkg to checkout from the VCS. For example, to checkout a given revision, the source line would have the format source=(url#revision=123). The available fragments depends on the VCS being used: bzr: revision (see 'bzr help revisionspec' for details) git: branch, commit, tag hg: branch, revision, tag svn: revision
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 branch --list master); echo $LOCAL index.php readme.md master $ LOCAL=$(git branch --list test/branch); echo $LOCAL test/branch The results aren't always consistent. Sometimes I get unexpected results from branches with forward slashes, sometimes without, depending on the repository I'm working with. I can't put my finger on what's happening exactly or why. Why does listing one branch list files in the directory and the branch itself, and the other one just lists the branch?
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-existing files. I think it should be possible to solve it using IFS, but IFS doesn't seem to work in cygwin and I doubt that something like rmdel = "!IFS=' ' git rm $(git ls-files -d)"` could work at all. Any better idea?
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 $ [ -d "/var/cache/git" ] || sudo mkdir /var/cache/git Setup gitweb's Apache config $ sudo vim /etc/apache2/conf.d/git contents of file: <Directory /var/www/git> Allow from all AllowOverride all Order allow,deny Options ExecCGI <Files gitweb.cgi> SetHandler cgi-script </Files> </Directory> DirectoryIndex gitweb.cgi SetEnv GITWEB_CONFIG /etc/gitweb.conf Copy gitweb files to Apache $ sudo mv /usr/share/gitweb/* /var/www/git $ sudo mv /usr/lib/cgi-bin/gitweb.cgi /var/www/git Setup gitweb.conf $ sudo vim /etc/gitweb.conf Contents of gitweb.conf: $projectroot = '/var/cache/git/'; $git_temp = "/tmp"; #$home_link = $my_uri || "/"; $home_text = "indextext.html"; $projects_list = $projectroot; $stylesheet = "/git/gitweb.css"; $logo = "/git/git-logo.png"; $favicon = "/git/git-favicon.png"; Reload/Restart Apache $ sudo /etc/init.d/apache2 reload Setup Git Repository $ mkdir -p /var/cache/git/project.git && cd project.git $ git init Configure Repository $ echo "Short project's description" > .git/description $ git config --global user.name "Your Name" $ git config --global user.email "[email protected]" $ git commit -a $ cd /var/cache/git/project.git && touch .git/git-daemon-export-ok Start Git Daemon $ git daemon --base-path=/var/cache/git --detach --syslog --export-all Test clone the Repository (from a secondary machine) $ git clone git://server/project.git project Adding additional Repos + Users To add more repos simply repeat steps #7 - #9. To add users just create Unix accounts for each additional user.
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 the entire contents of the commit, unfiltered by the filename. I.e. switch to a view that's the same as that generated if you run tig show d5dd1d658e5d79701fb9d028479a0fcb26a033fa: I've tried all the views and read the manual but haven't found a way. Is it possible?
% 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 wondering if there is a known faster method, or how I could find out. Whenever I run time git symbolic-ref HEAD, it simply outputs 0.00 real.
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/HEAD yourself but I doubt that it will make things faster.
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 key, all other hardware (the other servers and laptops) are using the ssh keys as before). Any of the macbooks can SSH into either of the servers (using the username/password of a user on the server) and they can use Git to clone, push, etc with the git server via public key. The site server can SSH (via public key) into the git server but once the welcome message appears the connection is terminated. The site server can not use git via public key as Git prompts for a password, except for when it doesn't and works using the public key which lasts for some time, it only starts to work using testing in the users documents directory, if I attempt to clone in the /var/www directory git breaks again (this may be coincidence, it has only worked twice). The CI has no issues connecting with the git server. Using ssh -v the output shows ssh is using the correct public key. So running the following command on the site server ssh [email protected] connects (and then disconnects) but git clone [email protected]:somerepo.git asks for the password of the git user. The site server has a user (with a ssh key) registered on gitlab. Example output from multiple calls: https://pastebin.com/QH0AntK7
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 commits with the PivotalTracker card by prepending [#1449242] to the beginning of the commit message. I would like this to be auto-inserted if git commit is typed in and the user hits TabTab. I have already done this here: https://github.com/tlehman/dotfiles/blob/master/ptid_git_complete (and for convenience, here is the source code): function _ptid_git_complete_() { local line="${COMP_LINE}" # the entire line that is being completed # check that the commit option was passed to git if [[ "$line" == "git commit" ]]; then # get the PivotalTracker Id from the branch name ptid=`git branch | grep -e "^\*" | sed 's/^\* //g' | sed 's/\-/ /g' | awk '{ print $(NF) }'` nodigits=$(echo $ptid | sed 's/[[:digit:]]//g') if [ ! -z $nodigits ]; then : # do nothing else COMPREPLY=("commit -m \"[#$ptid]") fi else reply=() fi } complete -F _ptid_git_complete_ git The problem is that this breaks the git autocompletion features defined in git-autocompletion.bash How can I make this function compatible with git-autocompletion.bash?
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 commit option was passed to git if [[ "$line" == "git commit " ]]; then # get the PivotalTracker Id from the branch name ptid=`git branch | grep -e "^\*" | sed 's/^\* //g' | sed 's/\-/ /g' | awk '{ print $(NF) }'` nodigits=$(echo $ptid | sed 's/[[:digit:]]//g') if [ ! -z $nodigits ]; then : # do nothing else COMPREPLY=("-m \"[#$ptid]") fi else __git_main fi } __git_complete git _ptid_git_complete_
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/autogen.sh *** WARNING: I am going to run 'configure' with no arguments. *** If you wish to pass any to it, please specify them on the *** './autogen.sh' command line. 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.sh: glib-gettextize: not found
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.sh: glib-gettextize: not found This message is telling you that you're missing a library. The internal logical name that this library goes by is this: AM_GLIB_GNU_GETTEXT. Searching for that will lead you to many threads like this one: https://ubuntuforums.org/showthread.php?t=1131769 APT Before we start looking, lets make sure our apt-file cache is updated: $ sudo apt-file update Now let's see what APT about this: $ apt-file search glib-gettextize libglib2.0-dev: /usr/bin/glib-gettextize libglib2.0-dev: /usr/share/man/man1/glib-gettextize.1.gz libglib2.0-doc: /usr/share/doc/libglib2.0-doc/glib/glib-gettextize.html Good so the package's name is libglib2.0-dev. This jives with what our previous Google search were returning. We can poke at this package to see if it has the .m4 file that we appear to be missing: $ apt-file list libglib2.0-dev | grep '.m4$' libglib2.0-dev: /usr/share/aclocal/glib-2.0.m4 libglib2.0-dev: /usr/share/aclocal/glib-gettext.m4 libglib2.0-dev: /usr/share/aclocal/gsettings.m4 Good, so there's an .m4 macro file that is what configure was looking for. So lets install it: $ sudo apt-get install -y libglib2.0-dev NOTE: Once it's installed you can query installed packages using dpkg: $ dpkg-query -L libglib2.0-dev | grep m4 /usr/share/aclocal/glib-2.0.m4 /usr/share/aclocal/gsettings.m4 /usr/share/aclocal/glib-gettext.m4 References How do I get a list of installed files from a package? autogen.sh fails #27
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, or perhaps from Windows, see the answer to How to create file execute mode permissions in Git on Windows?. This should result in the files having executable mode set on them as they are updated by git during a git pull or git checkout etc. ¹Note this can only work if you've cloned onto a filesystem that stores the executable bit +x and has been mounted in a way that allows it; some filesystems might not, such as NTFS or FAT32.
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 branch and then give the corresponding command as git pull --rebase origin <branch-name> I wanted to write an alias as git-rebase and what it would do is that first it will execute git branch. The output of git branch look like this experiment *master new feature So if we have two branches in addition to the master branch then it will show all the branches and the current branch will be star marked. I want to extract the star marked line and then pass the output of this to the above command. Also I would like to suppress the output of the command git branch. I am not doing this because I am too lazy to type the whole command, but because I would like to learn more about the power of unix bash. Hoping to learn something from it
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's answer). This should be ok, the awk command should always match exactly one line, and I'm assuming you can't have spaces in branch names. For anything much more complicated, I'd probably wrap it into a function (or a script) so you can do some sanity checking on the intermediate values.
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 safer but will obviously cause problems with software updates (the script gets overwritten). The shell function could look like this: git () { local cwd="$(pwd -P)" if ! [ "/path/to/src" = "$cwd" -o "/path/to/projects" = "$cwd" ]; then echo "The current working directory is: '${cwd}'" echo "git must not be run from here; from src and projects only." echo "Aborting." else command git "$@" fi }
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 listing. git config --global alias.s 'status --short'
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 donno as when I copy this to the shell it works fine): sh -c 'git remote add $0 $1: 1: sh -c 'git remote add $0 $1: Syntax error: Unterminated quoted string
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 colorize different part of the output and changes in config files proposed there are not applicable
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" then echo -e "\e[31m $i \e[0m" fi done to apply the script you would call it with: git diff --name-status | xargs --delimiter="\n" ./color_git_diff.sh Obviously you wouldnt want to call this everytime so you would need to put it into your bashrc and assign a function or an alias to it - or something like that. This only produces colorised output for modified or deleted files and I made modified files yellow - I dont know what the ansi escape code is for blue off the top of my head - I think maybe \e[36m ? anyway if you want to use it you can add it yourself-
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, but it isn't working: How can I do this? Edit: the possible duplicate is asking how escape characters, specifically ANSI color control sequences, work. I think I understand how they work. My question is how to preserve those in the script output.
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: grep also supports the --colors=always option. For git, the corresponding option is its color.ui configuration setting: git -c color.ui=always status
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 does not complete the absolute path. How can I tell zsh to complete absolute paths, as well as relative paths ? I am using zsh version 5.7.1-1 on Debian Buster.
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 case the used script is _git, the location order on $fpath is important as Zsh use the first _git script that it find and ignore the others if present (also similar to $PATH). Scripting: Like explained on this QA and as an example, the following function prepends $PWD/ to any relative path before passing it to _files, which is the normal completion function for files. _absolute_files () { local expansion=$PREFIX$SUFFIX; expansion=${(e)expansion} if [[ "${expansion%%/#}" != "${expansion:a}" ]]; then PREFIX="\$PWD/$PREFIX" fi _files "$@"; } This works in many common cases, including recognizing paths starting with ~/ and such as absolute... Solution: The default git completion behavior does not include relative paths, we could edit its script and add a function like the one on the explanation above to add support for relative path or we could simply replace the default git completion with the completion plugin gitfast from ohmyzsh with the following steps: Clone ohmyzsh to some location (let say /location): git clone https://github.com/ohmyzsh/ohmyzsh.git Edit ~/.zshrc and add at the bottom of the config file the following to include gitfast: fpath=( /location/ohmyzsh/plugins/gitfast $fpath ) The order is important as explained before and here. Update the completion cache by removing any ~/.zcompdump* then run compinit. Alternative solution: Editing /usr/share/zsh/5.5/functions/Completion/Unix/_git by applying the following patch on _git-diff function: --- _git +++ _git @@ -766,6 +766,12 @@ case $state in (from-to-file) + + if [[ $line[1] == *\/* ]]; then + _alternative 'files::_files' && ret=0 + return ret + fi + # If "--" is part of $opt_args, this means it was specified before any # $words arguments. This means that no heads are specified in front, so # we need to complete *changed* files only.
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 correctly. Correct message format\n #Ticket Number - Minimum 20 or more Character \n like #Android-123 Bug fixed for login issue" exit 1; fi So whenever I make a commit message like this: git commit -m " #Android-123 I pretty sure this is more than 20 character,but it still failed to commit" So I pretty sure my commit message is more than 20 character, and the ticket number, but every time I commit it still get the error I set. I think my logic problem is that I should use if not echo $msg | egrep -qv '(Android-\d{3,4}.{20,})', so I tried: if ! [[echo $msg | egrep -qv '(Android-\d{3,4}.{20,})']] ; then.... But this give me this error: .git/hooks/commit-msg: line 5: syntax error near unexpected token !' Question: What I going wrong that cause failed to commit, even though I make a right commit message? How can I fix it?
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 'Android-\d{3,4}.{20,}' If not, you will have to replace \d with [0-9]: grep -Eqv 'Android-[0-9]{3,4}.{20,}' However, you don't need (or want) to only take the first line of the file, you can just grep the whole file directly. You also don't need to reverse the match (-v), that just complicates things. Here's a simpler, working version of your script, using if ! to negate the condition: #!/bin/sh if ! grep -E 'Android-[0-9]{3,4}.{20,}' "$1"; then printf "[Message Format] Your message is not formatted correctly. Correct message format: #Ticket Number - Minimum 20 or more Character like #Android-123 Bug fixed for login issue\n" exit 1; fi
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 where devices repository has following configuration: repo devices RW = eng1 RW = eng2 RW = eng3 R = graphs SSH key-pair for user graphs is stored in mgmt-svr server in user graphs home directory and private key is readable and writable only for the user graphs. This private key is not password protected. Is there a more secure way to accomplish this? I thought about using HTTPS to access the devices repository in git server and basic access authentication, but I can't see any advantages over the current SSH based setup- I still need to store the access credentials somewhere in the user graphs home directory.
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 and some points for you to consider to make it better. Positive points about your setup Gitolite is itself light weight and well used enough with continuing updates. (last commit 23 days ago at time of writing). It's pretty secure. Gitolite piggybacks off OpenSSH server which is very well supported and extremely secure. Public private keys (such as SSH keys) are far more secure than passwords The setup is very simple giving you less to go wrong, and a cheap solution. Considerations for improvement Un-encrypted Keys Storing your private keys un-encrypted isn't perfect, though it is common. As you say you have to store them somewhere. However this can be a problem with backups or with servers that aren't physically secure. There are options which require you to manually decrypt your private keys when you reboot your server. Perhaps the simplest of these is an ssh agent and manually add your encrypted key to it when you reboot. SSH server hardening Remember that Gitolite runs under OpenSSH server. There are a number of things you can do to harden the ssh server itself. You might even consider running Gitolite under a chroot environment. There are many tutorials for how to setup chroot with OpenSSH. Remember that the result will need access to programs like python so this will make it more technically complex to achieve than many of the tutorials would have you believe. Social Engineering Every sysadmin looks for the technical ways a hacker can get in, but so many real world hacks are down to people. Perhaps the weakest point of your solution is the management of ssh keys. This is widely regarded to be a security issue in many businesses. Gitolite places all of the administration of SSH keys on the administrator. This carries some big implications: With no support for single sign on, the sysadmins may not know they need to remove access to this specific box when someone leaves. Eg: if your team is running this box for themselves, will they be notified the minute an employee is sacked? The naming convention inside Gitolite's config isn't great. It's very easy to make mistakes and delete or replace the wrong key. You need to come up with a directory structure for yourself that makes it absolutely clear what you are doing. Users may not tell you when they stop using a key. What they do with that key next may not be secure. Other, larger, software such as Github Enterprise actually has built in features for auditing SSH keys by disabling them on mass and asking users to re-approve them.
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_misspelled_locale_zhtw private-rl_1950_scheduler_offset private-rl_bootstrap_rake_tasks private-rl_1854_ldap_filter_reset private-rl_bootstrap_rake_task But some of the branches it shows don't exist anymore: :~/project $ git branch * develop private-rl_1219_misspelled_locale_zhtw stable This also happens for deleted remote branches. What's going on here? Does the git completion script keep a cache of old branches that can be flushed somehow? How can I stop these branches from accumulating in my tab-completion results?
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 this or something similar?
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 directory. I don't have any dotfiles in my home directory, only links into ~/.dotfiles. For example: $ ls -l ~/.muttrc lrwxr-xr-x 1 mj mj 25 May 4 2014 /home/mj/.muttrc -> /home/mj/.dotfiles/muttrc After I've cloned the repo onto a new machine (into ~/.dotfiles), I just run the script to update the symlinks. I've found the above approach works very well for me.
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 remote repository. Please make sure you have the correct access rights and the repository exists. From within my work network, on the same laptop it works fine using ssh. So now I switched to https and it works most of the time, but ocassionally it hangs and I get: fatal: The remote end hung up unexpectedly error: RPC failed; result=56, HTTP code = 0 From my work, this never happens, even if I try to commit the same changes just half an hour later. What could be the problem with ssh? Am I behind a router firewall or did my provider change something? EDIT 1: Output of git pull, adding LogLevel DEBUG3 to my .ssh/config: debug2: kex_parse_kexinit: none,[email protected] debug2: kex_parse_kexinit: none,[email protected] debug2: kex_parse_kexinit: debug2: kex_parse_kexinit: debug2: kex_parse_kexinit: first_kex_follows 0 debug2: kex_parse_kexinit: reserved 0 debug2: mac_setup: setup [email protected] debug1: kex: server->client aes128-ctr [email protected] none debug2: mac_setup: setup [email protected] debug1: kex: client->server aes128-ctr [email protected] none debug1: sending SSH2_MSG_KEX_ECDH_INIT debug1: expecting SSH2_MSG_KEX_ECDH_REPLY Connection closed by 54.93.71.23 fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. EDIT 2: The connection over https hangs ocassionally, but after many tests there were no MTU problems on my side. Probably the provider had some failures. Github and Bitbucket work perfectly fine over ssh. Thanks!
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 key 8975BA8B6100C6B1: Wrong key usage (0x19, 0x2) gpg: bad data signature from key DEA16371974031A5: Wrong key usage (0x19, 0x2) ...so I'm not sure if that could be interfering with my other problem: signing Git commits and getting gpg failed to sign the data failed to write commit object. This is the list of public/private keys that I have: [gorre@uplink ~]$ gpg --list-keys gpg: bad data signature from key 8975BA8B6100C6B1: Wrong key usage (0x19, 0x2) gpg: bad data signature from key DEA16371974031A5: Wrong key usage (0x19, 0x2) /home/gorre/.gnupg/pubring.kbx ------------------------------ pub rsa4096 2015-07-21 [SC] [expires: 2019-07-21] 94AE36675C464D64BAFA68DD7434390BDBE9B9C5 uid [ unknown] Colin Ihrig ... sub rsa4096 2015-07-21 [E] [expires: 2019-07-21] pub rsa4096 2014-04-01 [SCEA] [expires: 2024-03-29] FD3A5288F042B6850C66B31F09FE44734EB7990E uid [ unknown] Jeremiah Senkpiel ... uid [ unknown] keybase.io/fishrock ... sub rsa4096 2014-04-01 [SEA] [expires: 2024-03-29] pub rsa4096 2014-11-10 [SCEA] 71DCFD284A79C3B38668286BC97EC7A07EDE3FC1 uid [ unknown] keybase.io/jasnell ... uid [ unknown] James M Snell ... uid [ unknown] James M Snell ... sub rsa2048 2014-11-10 [S] [expires: 2022-11-08] sub rsa2048 2014-11-10 [E] [expires: 2022-11-08] pub rsa2048 2013-11-18 [SC] DD8F2338BAE7501E3DD5AC78C273792F7D83545D uid [ unknown] Rod Vagg ... uid [ unknown] Rod Vagg ... sub rsa2048 2013-11-18 [E] pub rsa4096 2016-01-12 [SC] C4F0DFFF4E8C1A8236409D08E73BC641CC11F4C8 uid [ unknown] Myles Borins ... uid [ unknown] Myles Borins ... uid [ unknown] Myles Borins ... uid [ unknown] Myles Borins (Not used after January 2017) ... sub rsa2048 2016-01-12 [E] [expires: 2024-01-10] sub rsa2048 2016-01-12 [SA] [expires: 2024-01-10] pub rsa4096 2015-12-17 [SC] [expires: 2019-12-17] B9AE9905FFD7803F25714661B63B535A4C206CA9 uid [ unknown] Evan Lucas ... uid [ unknown] Evan Lucas ... sub rsa4096 2015-12-17 [E] [expires: 2019-12-17] pub rsa4096 2016-04-07 [SC] 8FCCA13FEF1D0C2E91008E09770F7A9A5AE15600 uid [ unknown] Michaël Zasso (Targos) ... sub rsa4096 2016-04-07 [E] pub rsa4096 2016-10-07 [SC] 77984A986EBC2AA786BC0F66B01FBB92821C587A uid [ unknown] Gibson Fahnestock ... sub rsa4096 2016-10-07 [E] pub rsa4096 2018-06-12 [SC] B1BEB985FA77CDF913E2EAE88E0DCA371CC3F4EC uid [ultimate] Gorre ... sub rsa4096 2018-06-12 [E] [gorre@uplink ~]$ gpg --list-secret-keys /home/gorre/.gnupg/pubring.kbx ------------------------------ sec rsa4096 2018-06-12 [SC] MY_SECRET_KEY uid [ultimate] Gorre ... ssb rsa4096 2018-06-12 [E] UPDATE Looks like my initial issue was somehow with the gpg-agent; I ended up configuring $HOME/.gnupg/gpg-agent.conf as: [gorre@uplink ~]$ nano ~/.gnupg/gpg-agent.conf max-cache-ttl 86400 default-cache-ttl 86400 default-cache-ttl-ssh 86400 max-cache-ttl-ssh 86400 # Run pacman -Ql pinentry | grep /usr/bin/ for more options, I'm using Gnome 2.x pinentry-program /usr/bin/pinentry-gnome3 [gorre@uplink ~]$ gpg-connect-agent reloadagent /bye ...and everything works fine now – for what I wanted. Still, those errors are there, every time I execute the gpg command, but it looks like it doesn't impact the functionality of gpg – to the extent of what I do with it.
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 extent permitted by law. gpg: bad data signature from key ZZZZZZZZZZZZZZZZ: Wrong key usage (0x19, 0x2) Secret key is available. sec rsa4096/XXXXXXXXXXXXXXXX created: YYYY-MM-DD expires: never usage: SCEA trust: ultimate validity: ultimate ssb rsa2048/YYYYYYYYYYYYYYYY created: YYYY-MM-DD expires: YYYY-MM-DD usage: S ssb rsa2048/ZZZZZZZZZZZZZZZZ created: YYYY-MM-DD expires: YYYY-MM-DD usage: E [ultimate] (1). My Name <my@email> The subkey that gpg was complaining about bad signing from was ZZZZZZZZZZZZZZZZ, the second key, and indeed, that one was encrypt-only (usage: E), so I added Signing to that one: gpg> key 2 sec rsa4096/XXXXXXXXXXXXXXXX created: YYYY-MM-DD expires: never usage: SCEA trust: ultimate validity: ultimate ssb rsa2048/YYYYYYYYYYYYYYYY created: YYYY-MM-DD expires: YYYY-MM-DD usage: S ssb* rsa2048/ZZZZZZZZZZZZZZZZ created: YYYY-MM-DD expires: YYYY-MM-DD usage: E [ultimate] (1). My Name <my@email> gpg> change-usage Changing usage of a subkey. Possible actions for a RSA key: Sign Encrypt Authenticate Current allowed actions: Encrypt (S) Toggle the sign capability (E) Toggle the encrypt capability (A) Toggle the authenticate capability (Q) Finished Your selection? s Possible actions for a RSA key: Sign Encrypt Authenticate Current allowed actions: Sign Encrypt (S) Toggle the sign capability (E) Toggle the encrypt capability (A) Toggle the authenticate capability (Q) Finished Your selection? q sec rsa4096/XXXXXXXXXXXXXXXX created: YYYY-MM-DD expires: never usage: SCEA trust: ultimate validity: ultimate ssb rsa2048/YYYYYYYYYYYYYYYY created: YYYY-MM-DD expires: YYYY-MM-DD usage: S ssb* rsa2048/ZZZZZZZZZZZZZZZZ created: YYYY-MM-DD expires: YYYY-MM-DD usage: SE [ultimate] (1). My Name <my@email> Lastly, save the changes: gpg> save FWIW I used keybase a few years ago to generate this keypair, and I'm no gpg expert, so I don't know if this is the "proper" way to solve the issue, but it worked for me. Also, in the interests of full disclosure, there were actually two subkeys which were encrypt-only and I added Signing to both of them, but I edited the transcript above to make it clearer. YMMV.
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: DISPLAY This is the only mandatory environment variable. It must point to an X server. See section "Display Names" above. However, it might not be a good idea because someone could just set DISPLAY to a fake value even outside of X. A better way is suggested in this answer: if xhost >& /dev/null ; then echo "Display exists" else echo "Display invalid" ; fi You should have a program named xhost already installed on your machine, make sure you have it: $ type -a xhost xhost is /usr/bin/xhost Now, we could just set diff.external to point to a wrapper that would call an external diff if we're inside X and run the default git diff mechanism if we're not inside X. Unfortunately I'm not able to come up with a simple way to run a default git diff in diff.external so let's instead create an alias for git that would set diff.external temporarily using -c. As described in man git: -c < name>=< value> Pass a configuration parameter to the command. The value given will override values from configuration files. The is expected in the same format as listed by git config (subkeys separated by dots). Note that omitting the = in git -c foo.bar ... is allowed and sets foo.bar to the boolean true value (just like [foo]bar would in a config file). Including the equals but with an empty value (like git -c foo.bar= ...) sets foo.bar to the empty string. It would be something like: $ git -c diff.external=diff-wrapper.sh ... To sum up: Create a script called ~/git-wrapper.sh and replace <YOUR_DIFF_WRAPPER> with whatever you wish: #!/usr/bin/env sh if xhost >/dev/null 2>&1 then git -c diff.external=<YOUR_DIFF_WRAPPER> "$@" else git "$@" fi Set an executable bit: $ chmod +x ~/git-wrapper.sh Set alias in your shell startup file, for example ~/.bashrc and reload shell: alias git=~/git-wrapper.sh Use git normally: $ git diff It will use <YOUR_DIFF_WRAPPER> if you're inside X and will use default git-diff outside of X.
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 reading the logs with git log. Is there a hook script, I can use for this?
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 apt-get or emerge operation do get a meaningful messages listing the packages that got installed, upgraded or removed.) You need to run etckeeper commit or $vcs commit and enter a meaningful message. To prevent apt-get or emerge from running if there are uncommitted changes, edit /etc/etckeeper/etckeeper.conf and uncomment the line AVOID_COMMIT_BEFORE_INSTALL=1 (and AVOID_DAILY_AUTOCOMMITS=1 if it's commented out).
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 ... to myfile.conf" 5) Observe the commit : git log -p -1 [...] maybe chmod 0644 'magic.mime' -maybe chmod 0644 'mail.rc' maybe chmod 0644 'mailcap' maybe chmod 0644 'mailcap.order' maybe chmod 0644 'mailname' +maybe chmod 0644 'mail.rc' maybe chmod 0644 'manpath.config' maybe chmod 0644 'matplotlibrc' maybe chmod 0755 'maven' [...] (My modification to myfile.conf) [...] I understand that etckeeper need to keep track of file permissions in the git repository even if I don't understand the purpose of this reordering. I would like to separate in distinct commits all modifications related to the ./etckeeper directory and modifications related to the content of the configuration files. How to do it?
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 your case, the file appears to have been sorted in a pure byte lexicographic order (with mail.rc before mailcap since . is before c in ASCII), but you are now running git in a locale where sorting is done in a somewhat human-friendly way, with punctuation ignored except as a last resort (probably a UTF-8 locale) (with mail.rc after mailname since n is before r). Run LC_ALL=C git commit to do the sorting in pure lexicographic order. It would make sence to add export LC_COLLATE=C to /etc/etckeeper/etckeeper.conf to force a consistent sorting order.
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 account: curl -u "user:pass" --data '{"title":"test-key","key":"`cat ~/.ssh/id_rsa.pub`"}' https://api.github.com/user/keys but it is giving error. What could be the reason?
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":"'`cat ~/.ssh/id_rsa.pub`'"}' https://api.github.com/user/keys
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 of colors, as I verified by setting git config color.ui always and running git log | cat. However I can't use cat as my pager, for obvious reasons. Is there an alternative to less -R that works on busybox? Or some other pager I could install and use with git for color capabilities?
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 13:09:52 is 49.814349986 s in the future another/file.txt tar: another/file.txt: time stamp 2014-10-29 13:09:52 is 49.813794938 s in the future This all happens within seconds on a single machine.
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 relative to the moment when you ran git archive. Perhaps that commit was fetched from a remote repository with an incorrect clock, or the local clock is incorrect?
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 work anymore. The same goes for a git-all function to run the same git command in all repositories in sub-directories git-all() { if [ "$#" -eq 0 ]; then find . -maxdepth 3 -type d -name .git -execdir echo \; -execdir pwd \; -execdir git status --short --branch \; else find . -maxdepth 3 -type d -name .git -execdir echo \; -execdir pwd \; -execdir git "$@" \; fi } alias ga='git-all' I would like to have completion for all these, g, git-all, and ga, just like for git. The docs say If you want a command, say cmd1, to have the same completions as another, say cmd2, which has already had completions defined for it, you can do this: compdef cmd1=cmd2 So, I type compdef git-all=git in my current zsh session, and it works! Nice. So, I put the compdefs in my .zshrc after my antigen setup, which has zsh-users/zsh-completions to init the completions, and after my alias and function definitions if [ -f ~/.antigenrc ]; then source ~/.antigenrc fi if [ -f ~/.sh_aliases ]; then source ~/.sh_aliases fi compdef g=git compdef ga=git compdef git-all=git antigen apply And my antigenrc looks like this: source /usr/share/zsh-antigen/antigen.zsh antigen use oh-my-zsh antigen bundle gradle/gradle-completion antigen bundle command-not-found antigen bundle MikeDacre/cdbk antigen bundle zsh-users/zsh-completions antigen bundle zsh-users/zsh-syntax-highlighting antigen theme ys and I start a new zsh shell. Now the completions don't work. How can that be? An interactive zsh shell reads the .zshrc (if I put an echo in there, I see the output). If I put the compdef before the antigen setup, I get errors about compdef not being defined, but when they are at the end they don't show errors, they just don't work. Maybe antigen is doing something strange, but even then, the completions are defined after the antigen setup, so antigen shouldn't mess them up? I also tried adding _git 2>/dev/null to my .zshrc as suggested here, or using compdef '_dispatch git git' g as suggested here, to no avail. My zsh version is 5.8.
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 know it's not the proper way of fixing it and that it can cause some other errors, but I'm heavily using kubectl so I need autocompletion so much The function compdef () {} obviously doesn't do anything and is what is called in my .zshrc. The quoted workaround didn't work for me, because the .antigen/init.zsh is (re-)generated by antigen, but what works for me is to put autoload -U +X compinit && compinit before my compdefs in my .zshrc: #type compdef #uncomment this to see the problem autoload -U +X compinit && compinit #type compdef #uncomment this to see the solution compdef g=git compdef ga=git compdef git-all=git
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 * ~/somefolder $ git commit -a -m . [master (root-commit) 591fda9] . 2 files changed, 2 insertions(+) create mode 100644 somefolder2/zzz create mode 100644 xyz When turning the whole repository into a tar.gz, it results in a determinstic file. Example. ~/somefolder $ git archive \ > --format=tar \ > --prefix="test/" \ > HEAD \ > | gzip -n > "test.orig.tar.gz" ~/somefolder $ sha512sum "test.orig.tar.gz" e34244aa7c02ba17a1d19c819d3a60c895b90c1898a0e1c6dfa9bd33c892757e08ec3b7205d734ffef82a93fb2726496fa16e7f6881c56986424ac4b10fc0045 test.orig.tar.gz Again. ~/somefolder $ git archive \ > --format=tar \ > --prefix="test/" \ > HEAD \ > | gzip -n > "test.orig.tar.gz" ~/somefolder $ sha512sum "test.orig.tar.gz" e34244aa7c02ba17a1d19c819d3a60c895b90c1898a0e1c6dfa9bd33c892757e08ec3b7205d734ffef82a93fb2726496fa16e7f6881c56986424ac4b10fc0045 test.orig.tar.gz Works. But when changing a minor detail, when only compressing a sub folder, it does not end up with a deterministic file. Example. ~/somefolder $ git archive \ > --format=tar \ > --prefix="test/" \ > HEAD:somefolder2 \ > | gzip -n > "test2.orig.tar.gz" ~/somefolder $ sha512sum "test2.orig.tar.gz" b523e9e48dc860ae1a4d25872705aa9ba449b78b32a7b5aa9bf0ad3d7e1be282c697285499394b6db4fe1d4f48ba6922d6b809ea07b279cb685fb8580b6b5800 test2.orig.tar.gz Again. ~/somefolder $ git archive \ > --format=tar \ > --prefix="test/" \ > HEAD:somefolder2 \ > | gzip -n > "test2.orig.tar.gz" ~/somefolder $ sha512sum "test2.orig.tar.gz" 06ebd4efca0576f5df50b0177d54971a0ffb6d10760e60b0a2b7585e9297eef56b161f50d19190cd3f590126a910c0201616bf082fe1d69a3788055c9ae8a1e4 test2.orig.tar.gz No deterministic tar.gz this time for some reason. How to create a deterministic tar.gz using git-archive when just wanting to compress a single folder?
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/archive.c b/archive.c index 94a9981..0ab2264 100644 --- a/archive.c +++ b/archive.c @@ -368,7 +368,7 @@ static void parse_treeish_arg(const char **argv, archive_time = commit->date; } else { commit_sha1 = NULL; - archive_time = time(NULL); + archive_time = 0; } tree = parse_tree_indirect(sha1);
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 the www-data user to be able to write there. The www-data user has its home set to /var/www and it's ssh keys are in /var/www/.ssh . If I run: sudo git clone [email protected]:user/repo.git It works as expected - the ssh public key for my user is listed as in authorized_keys @ my.git.server. However I need to run from a bash script and with normal privileges. So I copied the public ssh key for the www-data user to the authorized_keys file at my.git.server. In theory that should mean the www-data user can initiate git clone over ssh removing the need for passwords and being pretty secure. So to test it I think I need to run something like: sudo -u www-data -H git clone [email protected]:user/repo.git My understanding is that would let me assume the identity of the www-data user, set my home directory so that ~/.ssh is in the working directory when the git clone over ssh is issued. The issue I have is the following error output when I try to execute that command: Cloning into 'repo'... fatal: 'user/repo.git' does not appear to be a git repository fatal: Could not read from remote repository. Like I said if I run as sudo - no issue. Only when I try to run as www-data. It feels like there's an issue with the way the command is being interpreted that forces it to read the path / repo name incorrectly ? Following on from l0b0's response, the output is as follows: james-c@WebHost-1:~$ sudo ssh -v [email protected] 2>&1 | grep 'identity file' debug1: identity file /root/.ssh/id_rsa type -1 debug1: identity file /root/.ssh/id_rsa-cert type -1 debug1: identity file /root/.ssh/id_dsa type -1 debug1: identity file /root/.ssh/id_dsa-cert type -1 debug1: identity file /root/.ssh/id_ecdsa type -1 debug1: identity file /root/.ssh/id_ecdsa-cert type -1 debug1: identity file /root/.ssh/id_ed25519 type -1 debug1: identity file /root/.ssh/id_ed25519-cert type -1 james-c@WebHost-1:~$ sudo -u www-data ssh -v [email protected] 2>&1 | grep 'identity file' debug1: identity file /var/www/.ssh/id_rsa type 1 debug1: identity file /var/www/.ssh/id_rsa-cert type -1 debug1: identity file /var/www/.ssh/id_dsa type -1 debug1: identity file /var/www/.ssh/id_dsa-cert type -1 debug1: identity file /var/www/.ssh/id_ecdsa type -1 debug1: identity file /var/www/.ssh/id_ecdsa-cert type -1 debug1: identity file /var/www/.ssh/id_ed25519 type -1 debug1: identity file /var/www/.ssh/id_ed25519-cert type -1 Not exactly sure what I'm looking for here ?
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/deploydeputy && git clone [email protected]:inventid/cdn.git /tmp/cdn"
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 computers. It comes with the package manager and as such will be installed outside my home directory. It is not installed on the server and it won't be installed on the server. I now have two options: I install it with the package manager locally and install it on the remote server by hand. This way the files are not in sync. That's somewhat okay, since the file comes from the package manager, it's not really a file I'm working on. However, I always need to install it separately when moving to a new server, and this happens frequently. I could add a shell script that installs the package and add this shell script to the git repository, though. I install it locally in my home directory and add it to the repository. This way I don't have to install it separately on different machines, it is kept in sync, but it is not updated anymore through the package manager. That's what I'm doing right now. And here's the question: Is there a third - better - way how to do this? any git symbolic link magic?
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 git commit hook, to run this script so that you're always in sync. [Moved from comment to answer on request]
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 consider this behaviour a feature). 59 * * * * cd FQNameOfRepo; git pull 1>/dev/null; make doc-all 1>/dev/null; cp doc/latex/refman.pdf doc/html/ While I could grep through the stderr output of Git or compare it to a known string this seems wrong. Am I using the wrong Git command? How would this be done properly? For clarification I still want this command to send a mail if a real error occurs, so simply redirecting stderr won't help.
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 example, the Solaris crond has a (relatively) small size limit on the output it captures/mails. Thus, for such situations, I suggest writing a small helper script that calls the commands and redirects the output to a temporary log-file. It can internally keep track of the exit status of all the programs and if one is != 0 it either: cat the log-file to stdout mail it via a command line mail tool or just output short diagnostics that include the location of the log-file Something like: $ cat helper.sh set -u set -e # setup log-file $LOG # ... cd FQNameOfRepo set +e git pull 1>/dev/null 2>> $LOG r1=$? make doc-all 1>/dev/null 2>> $LOG r2=$? cp doc/latex/refman.pdf doc/html/ 2>> $LOG r3=$? set -e if [ $r1 -ne 0 -o $r2 -ne 0 -o $r3 -ne 0 ]; then # do some stuff, print/mail $LOG or something like that, etc. # ... exit 23 fi
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 thought of replacing vi with vii, and did. But the problem is when I do git commit, instead of opening the vim in insert mode, it gives this error: error: cannot run vii: No such file or directory error: There was a problem with the editor 'vii'. Please supply the message using either -m or -F option. This makes clear that git does not looks to .bash_aliases file, even it isn't related to bash in any way. It does directly looks if there is /usr/bin/vii or not. And executes it if it is. The Question Can I place the aliased version of vi as vii in /usr/bin/? (and please don't suggest me to use git commit -m "<commit message>". There are other situation where I need vim in insert mode.)
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 'startinsert' and put it preferably in /usr/local/bin/ (or $HOME/bin, if it exists and is in your search path). The script only needs to contain #!/bin/sh1 exec vim -c 'startinsert' "$@" 2 (Make sure to make it executable by running chmod +x /usr/local/bin/vii.) Depending on the PATH configuration of your git/other programs, you may need to specify full path to that wrapper script (i.e., editor = /usr/local/bin/vii). If it is ok for you to have vim always start in insert mode, configure it to do so by adding startinsert at the end of .vimrc. 1   You can write the "she-bang" line as #!/bin/bash, but there's no need to in a script that contains no bashisms. 2   $@ must be in double quotes in case the script is ever called with argument(s) that contain space(s). startinsert does not need to be quoted (but it doesn't hurt).
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.thegeekstuff.com/2011/08/git-install-configure/, but I'm obviously missing something)
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 && git push --delete origin $1 However, this fails with the following error: fatal: branch name required
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 conditional logic, looping, etc. however when parameters are needed I switch to using functions Git itself also allows aliases, for example see: How does this git alias work? How can I create an alias for a git [action] command (which includes spaces)? You may also find Git alias multi-commands with ; and && helpful
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 character (a,b,c,...). This comes from the POSIX definition of a text file. This can cause problems in some languages such as shell scripts (sh, bash, zsh, ksh, ...). If you are lucky the script will fail on a syntax error caused by a spurious extra argument. However in bad cases this can creep into the content of files and file names. This is mostly a problem for tools and languages which are only designed to run under linux / unix. Many platform independent languages and tools auto adapt. So you are unlikely to see a problem an IDE, or code editor. So to attempt to end your argument with your colleagues, no linux does not have a problem with CRLF line endings. However some tools and languages can choke or do strange things if you leave them in. If you are writing code to be run on Linux / Unix platforms then it's generally easier to configure git to strip any CR characters for you leaving you with LF line endings.
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: [pager] cdiff = diff-highlight [alias] cdiff = "diff -w --ignore-blank-lines -I'^#'" When I do git cdiff, I get this error: error: invalid option: -I^# UPDATE2: this is so frustrating. The syntax git diff -G'^[^#]' does not work reliably. Example: $ cat 1.txt aaa bbb ccc ddd eee fff ggg hhh iii jjj initialize new git repo: $ git init && git add . && git commit -m "initial commit" -a add only comment on top of file: $ cat 1.txt # comment aaa bbb ccc ddd eee fff ggg hhh iii jjj so far, it works as expected. git diff -G'^[^#]' does not show the comment as change. But if I add a real change at the last line, and then do git diff -G'^[^#]' again, it then shows the added last line (as it should), but also the first line comment which it did not show before. So basically, as soon as I add any non-comment change, git shows everything, even comments.
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 configure the current repository). Finally, set git attributes to have this helper used on all files: echo '* diff=nocomments' >> .gitattributes (in the top directory of your repository). git diff will now ignore any lines starting with #. Note that this will affect line numbering. If you want this as an alias, rather than overriding all uses of git diff, skip the git config command above and create your alias as follows: git config alias.cdiff '-c diff.nocomments.textconv=stripcomments diff' Now git cdiff will run git diff with # comments stripped out. You can configure all this globally, rather than for each repository, by using git config --global and storing attributes in $XDG_CONFIG_HOME/git/attributes (~/.config/git/attributes) instead of .gitattributes. See man gitattributes and man git-config for details.
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 ls but sorted by date-time. Is it possible?
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 I store RFC-related stuff, it looks like this: . ├── TheFile └── tests ├── 4180 │   └── data │   ├── bad │   └── good │   └── linebreaks.csv ├── get-rfc.sh ├── .git <contents omited> ├── LICENSE ├── README └── rfc4180.txt I'm looking for a command that will output me: TheFile
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 directory, and if test says there is a sub-directory called .git and if prune returns true then we are done processing this thing in the tree". The right hand side says "otherwise print it" If you don't want directories printed then change -print to \( ! -type d -print \) but then you will not get any indication about empty directories. You can change the -print to -ls to get listings, -printf see manual etc etc.
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] ]]; then vim -p $(git diff --diff-filter=AM --ignore-submodules --name-only HEAD^) fi The down fall is if I add or change a binary file in the previous commit then it will be opened by the editor (Vim in this case). Is there a way to take the list outputted by the git diff command and remove binary files?
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 "")) read -p "Open ${#files[@]} files in Vim tabs? (Y/n)" -n 1 -r if [[ -z $REPLY || $REPLY =~ [Yy] ]]; then exec vim -p ${files[@]} else exit 1 fi
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 45c09bfe58c37bbf7965af25bdd4fa5c37c0908f:src/intel_driver.h > intel_driver.h but how can I extract the whole structure (all files) ?
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 45c09bfe58c37bbf7965af25bdd4fa5c37c0908f | gzip >../45c09bfe58c37bbf7965af25bdd4fa5c37c0908f.tar.gz git archive --prefix=45c09bfe58c37bbf7965af25bdd4fa5c37c0908f/ 45c09bfe58c37bbf7965af25bdd4fa5c37c0908f | tar xf - -C .. git archive gives you a tar archive, which you can extract elsewhere or store to a file.
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 user to restart apache, without requiring sudo? I want to restrict option to only restarting Apache, and only this particular user.
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 pull because i'd like everyone to be able to pull from our development server. How do i configure git to have the proper permissions to just be able to pull without sudoing? Is this because I may have not configured git properly? If so how do i configure git to allow the correct permissions? Not sure if this helps but a which git reveals this: /usr/bin/git Example error i execute: git commit -m "my fun message" i get: error: Unable to append to .git/logs/refs/heads/stage: Permission denied fatal: cannot update HEAD ref
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 Understanding UNIX permissions and chmod.
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 really don't like having to enter in quotes, so I am looking to do: ores_simple_push my git commit message here gets put into a single string so that would become: git commit -am 'my git commit message here gets put into a single string' is there a sane way to do this?
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 ksh/zsh/bash/yash (the Bourne-like shells with array support), that's the same for "${array[@]}" vs "${array[*]}". In zsh, "$array" is the same as "${array[*]}" while in ksh/bash, it's the same as "${array[0]}". In yash, that's the same as "${array[@]}". In zsh, you can join the elements of an array with arbitrary separators with the j parameter expansion flag: "${(j[ ])array}" to join on space for instance. It's not limited to single character/byte strings, you can also do "${(j[ and ])array}" for instance and use the p parameter expansion flag to be able to use escape sequences or variables in the separator specification (like "${(pj[\t])array}" to join on TABs and "${(pj[$var])array}" to join with the contents of $var). See also the F shortcut flag (same as pj[\n]) to join with line-feed. So here: ores_simple_push() ( set -o errexit -o pipefail git add . git add -A args=("$@") if [[ ${#args[@]} -lt 1 ]]; then args+=('squash-this-commit') fi IFS=' ' git commit -am "${args[*]}" || true git push ) Or just POSIXly: ores_simple_push() ( set -o errexit git add . git add -A [ "$#" -gt 0 ] || set square-this-commit IFS=' ' git commit -am "$*" || true git push ) With some shells (including bash, ksh93, mksh and bosh but not dash, zsh nor yash), you can also use "${*-square-this-commit}" here. For completeness, in bash, to join arrays with arbitrary strings (for the equivalent of zsh's joined=${(ps[$sep])array}), you can do: IFS= joined="${array[*]/#/$sep}" joined=${joined#"$sep"} (that's assuming $sep is valid text in the locale; if not, there's a chance the second step fails if the contents of $sep ends up forming valid text when concatenated with the rest). ¹ As a historical note, in the Bourne shell, they were joined with SPC regardless of the value of $IFS
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 branch" is that you develop the feature independently, and then merge it into your mainline development branch later. But, I don't know anything about your workflow or what you're ultimately trying to accomplish, so it's really up to you to decide if this is something you'd really need to do (or if it is actually a good idea or not).
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\[3[12]m' However, this does not work either and I still get this error: fatal: bad config line 17 in file /home/me/.config/git/config A comment under that answer suggests that the problem is due to the quotes.
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 second attempt is not valid because Git parses the backslashes, you need to double them, and double the backslash in front of [ since the shell must see \\[ in order for grep to see \[: mdiff = ! git diff --color | grep --color=never $'\\e\\\\[3[12]m' But this is not right because git mdiff foo is equivalent to running the shell command git diff --color | grep --color=never $'\\e\\\\[3[12]m' foo You need to arrange to pass the arguments to git. You can do that by defining a function and then executing it. You need to take care because ; needs to be quoted. This works on the Git side: mdiff = ! "f () { git diff --color \"$@\" | grep --color=never $'\\e\\\\[3[12]m'; }; f" This only works if /bin/sh is bash, though, not if it's dash. Dash doesn't support the $'…' escape syntax. If /bin/sh is dash, you need to produce the escape character with printf. mdiff = ! "f () { git diff --color \"$@\" | grep --color=never $(printf '\\033\\\\[3[12]'); }; f" If all you want to do is remove the context (but keep file names and position indicators), that's built in: git diff -U0.
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 inside repo { git fetch git diff master origin/master } &> /dev/null if [ "" = $? ] then echo "Empty" # logic to follow else { git pull } &> /dev/null echo "Don't forget to rebase!!!" echo $REPO_PATH fi # check for changes to master # If master is behind origin/master # then pull master and notify me to rebase # run this at the start of the day (this script should be run from my start_work # script and should also be periodically run throughout the day. [maybe every # time I'm about to run coverage/push?]) Anybody have any ideas?
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 extra rpi-update extra sonic-pi extra ssh extra triggerhappy extra wireless-tools extra xkb-data extra adduser important apt important apt-utils important aptitude important aptitude-common important bsdmainutils important ... I have recently run a script that installed way to many things and now my machine responds with: /usr/bin/mandb: can't write to /var/cache/man/2694: No space left on device (the paths change but it always tells me there is no space left.) The possible labels I see are: standard extra important optional required I have uncommitted changes in various repos and I want to be able to push my local changes but I keep getting this error when I attempt to push: $ git push fatal: write error: No space left on device error: Couldn't write .git/refs/remotes/origin/master.lock error: Cannot update the ref 'refs/remotes/origin/master'. Everything up-to-date I should also say that I know everything is not up to date. The System: This is on a raspberry pi running "wheezy" raspbian. The question: I have several hundred packages installed. How do I remove all packages labeled 'extra'? Is this the best way to free space on my machine? I have uncommitted changes in various repos and I want to be able to push my local changes. I would also accept an answer that removes everything but required and important. Git is labeled under optional and I would prefer to keep this (though I can always install it again after removing all unneeded packages). Thanks in advance!!
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 uninstall packages. You will need to reinstall git, as it will be removed along with the other optional and extra packages. You might need some optional and extra packages, so remove with care. More here: https://askubuntu.com/questions/79665/keep-only-essential-packages
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 Solution Maybe I can copy my files from linux server to my local machine disk and then run an script that listen to changes made in my local files and mirror it to my remote server. I am using Git, any solution should cover git files too. In case I'm losing my connection I should be able to continue my work on local files and as soon as connection established script should mirror my changes to remote server. My machine runs Mac OSX Lion.
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 repo to the computer you want to work from (git clone <remote-repo>), work as normal (code, git add, git commit, rinse and repeat), and then push back to the remote repo when you're done and have a working internet connection (git push origin master or whatever your remote / branch is called if you didn't go with the defaults). Git downloads a full copy of the repo, including all history, by default; so not having an internet connection shouldn't matter. You can just keep working and sync up with your remote machine when the internet comes back on. If you're looking for a way to automatically push every time a commit is made, check out git hooks. The post commit hook is probably what you want. Just navigate to the .git/hooks directory inside your git repo and rename the file post-commit.sample to post-commit, or create it and make sure it's executable (chmod +x post-commit) if it doesn't exist. Now anything you put into this script will be executed right after you make a commit, for instance, you seem to want: #!/bin/sh git push origin master You could also use the post-receive hook on the remote machine to do something every time it receives a push from your local repo. EDIT: In a comment you stated that "pushing manually won't work"; however, git supports pushing via SSH, which is probably how you're managing your server anyways. If not, it can also push via FTP (shudder) and other protocols including HTTP[S] if you configure your server properly. You should probably look into using git this way, as this is how it was designed to be used.
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 up unexpectedly $ git clone /home/myuser/git3 Cloning into git3... done. Why is ssh failing? I can clone it by using the local path, and whoami shows myuser -- I am not root. Just to make sure I have the addr right I wrote ssh [email protected] -p 1234 by copy/pasting the info rather then typing it. I don't understand why ssh isn't working. I know i had it working on this remote box, but I upgraded from debian lenny to squeeze and recently I made various config changes. I don't understand why I can't use git with ssh here.
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-highlight | less -FRX }
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 the file permissions within any of the folders. This is a problem as now git thinks all of my files permissions have changed. » ll README.txt -rwxrwx--- 1 root vboxsf 4.5K Oct 28 10:42 README.txt » chmod 644 README.txt » ll README.txt -rwxrwx--- 1 root vboxsf 4.5K Oct 28 10:42 README.txt » sudo chmod 644 README.txt » ll README.txt -rwxrwx--- 1 root vboxsf 4.5K Oct 28 10:42 README.txt » git diff README.txt | cat diff --git a/README.txt b/README.txt old mode 100644 new mode 100755 How do I fix this? The folder was mounted using Automount from the VirtualBox Manager on windows.
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 has the disadvantage that you cannot access the data when the VM is not running.
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-shell-commands/ && tree . ├── addkey ├── create ├── drop ├── help └── list But ssh'ing in is still giving me Last login: Fri Nov 15 12:14:49 2013 from localhost fatal: What do you think I am? A shell? Connection to localhost closed. I am working off of this resource Hosting an admin-friendly git server with git-shell There was some confusion that this was licensed GIT commands (push/pull etc) but this is a restricted shell with pre set commands! Please anyone reading this make note ;) Installer script if you want to see steps https://github.com/ehime/bash-tools/blob/master/git-server-setup.sh I still have not been able to resolve this over the weekend, I HAVE added # add to shells echo '/usr/bin/git-shell' >> /etc/shells # Prevent full login for security reasons chsh -s /usr/bin/git-shell git And have double checked that GIT Shell actually exists in /usr/bin [root@domain bin]# ll /usr/bin | grep git -rwxr-xr-x. 105 root root 1138056 Mar 4 2013 git -rwxr-xr-x. 1 root root 1138056 Mar 4 2013 git-receive-pack -rwxr-xr-x. 1 root root 457272 Mar 4 2013 git-shell -rwxr-xr-x. 1 root root 1138056 Mar 4 2013 git-upload-archive -rwxr-xr-x. 1 root root 467536 Mar 4 2013 git-upload-pack This IS a root account that I am dealing with though, could that have something to do with it?
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 for RHEL systems # CPR : Jd Daniel :: Ehime-ken # MOD : 2013-11-18 @ 09:28:49 # REF : http://goo.gl/ditKWu # VER : Version 1.1 # ROOT check if [[ $EUID -ne 0 ]]; then echo "This script must be run as su" 1>&2 ; exit 1 fi yum install -y perl-ExtUtils-MakeMaker gettext-devel expat-devel curl-devel zlib-devel openssl-devel cd /usr/local/src git clone git://git.kernel.org/pub/scm/git/git.git && cd git make && make prefix=/usr install git --version exit 0 Thanks to everyone who took the time to look into this, I appreciate it greatly.
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/username, then it works fine. Is there way to use ~ expression for git remote with ssh protocols?
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 cgit add .ssh/config cgit would try and add /.ssh/config to the /.git repo. Any suggestions or work-arounds?
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 sudo git --git-dir=/.git $@ > /dev/stdout FTR, I haven't tried it.
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: [[ -n "$(git status --porcelain 2> /dev/null | tail -n1)" ]] && git_c=220 || git_c=34 The problem I am having is, that when I change a file by adding a comment, my filter strips the comment, and the file for gits purposes should be unchanged. I can verify that by git diff which shows no difference. But git status shows the file has changed, and consequently my shell shows yellow prompt, indicating uncommited changes. What do I have to use to solve this problem? EDIT: what is even worse, when I do git status, it shows me modified files. When I do git diff it shows no changes. And when I do git commit, it tells me nothing to commit. So in other words, git status shows changed file but I am unable to commit.
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 the filter, and compares. As long as the comment changes get filtered out, there is no change. However, if the file size is different, git status does not run the filter at all, and does not even look at file contents. A change in file size alone is enough to make git status consider the file as changed. Comparing file sizes instead of file contents is a common optimization. Which, in this case, works against you. And there doesn't seem to be an option to turn it off. There is core.checkStat = minimal which disables almost everything except the filesize check. So that's a dead end. If there is any other option related to this issue, I couldn't find it. So I don't have a proper solution to change git status behavior. You might have to switch to a different command altogether (run git diff? or git commit --dry-run so it doesn't actually commit?). These tools run the filter (and then do nothing) since they actually have to look at the file contents to diff/commit the changes. Otherwise, run git add to update the cached filesize in git? (no commit involved) Another (weird) option would be to force the filesize issue. For text files you can just append comments, then truncate the files to always be of the same size. So the filesize never changes and git status does have to check the file contents for you. That would make git status work for your use case but it's hardly practical. A more radical approach would be to patch git itself. diff --git a/read-cache.c b/read-cache.c index 35e5657877..4e087ca3f5 100644 --- a/read-cache.c +++ b/read-cache.c @@ -213,7 +213,7 @@ int match_stat_data(const struct stat_data *sd, struct stat *st) #endif if (sd->sd_size != (unsigned int) st->st_size) - changed |= DATA_CHANGED; + changed |= MTIME_CHANGED; return changed; } This would pretend a size change is merely a time change (and then kick off the file contents comparison later on). However, this would only work for you locally and this is very risky. After all, this function is responsible for the integrity of your git repository and I can't judge if such a change is safe in any way at all. If you do anything like this you should call it frankengit and make sure it can't modify your repository at all (at minimum, add --no-optional-locks to the status command). Same question, asked 9 years ago: Why does 'git status' ignore the .gitattributes clean filter? Git mailing list discussion: git filter bug Nothing came of it apparently but if you care about this feature, you should take it up with the mailing list one more time regardless. Otherwise the same issue will still be around another 9 years later. ;-)
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 collection of tools that does this for the purpose of placing your /etc directory under version control. You might want to adapt it to your purposes, or perhaps study what it does to do something similar yourself.
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 git folder: /home/h/usr/praktikum to run my git commands?
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 also used by GNU autotools configure scripts and Meson, while CMake uses -DCMAKE_INSTALL_PREFIX. Usually, the default installation prefix is /usr/local, but setting it to someplace else would allow you to install the software in a clean, previously unpopulated, file hierarchy. Using this --prefix option to install in a non-default location such as /tmp/testdir, you would be able to investigate the installation directory to see exactly what is installed (assuming that the script is using the given path as a true installation prefix and does not try to install anything outside of that path; you will have to read the script to find out if that is the case).
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. How can I see only changes relating to 3.18 ? How can I see, for example, which files have been changed between 3.18.6 and 3.18.7 ?
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 etckeeper manually I sometimes have to configure it (init) before it starts working. Here's the info about that from the readme: The etckeeper init command initialises an /etc/.git/ repository. If you installed etckeeper from a package, this was probably automatically performed during the package installation. If not, your first step is to run it by hand: etckeeper init I would like a script that will install it and have it init'd automatically with no end-user intervention required.
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/home:/Peuserik:/OSSFAC/openSUSE_12.3/noarch/etckeeper-1.3-2.1.noarch.rpm install it: sudo zypper in etckeeper-1.3-2.1.noarch.rpm initialize it: sudo etckeeper init So the script would be: #!/bin/sh wget http://download.opensuse.org/repositories/home:/Peuserik:/OSSFAC/openSUSE_12.3/noarch/etckeeper-1.3-2.1.noarch.rpm sudo zypper in etckeeper-1.3-2.1.noarch.rpm sudo mv /etc/etckeeper/etckeeper.conf /etc/etckeeper/etckeeper.conf.original sudo tee /etc/etckeeper/etckeeper.conf > /dev/null << ENDDOC HIGHLEVEL_PACKAGE_MANAGER=zypper LOWLEVEL_PACKAGE_MANAGER=rpm VCS="git" ENDDOC #no space before this line cd etc sudo etckeeper init sudo git commit -m "initial checkin" sudo git gc # pack git repo to save a lot of space cd - exit 0
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 ---> Package git.x86_64 0:1.8.2.1-1.el5 will be installed --> Processing Dependency: perl-Git = 1.8.2.1-1.el5 for package: git-1.8.2.1-1.el5.x86_64 --> Processing Dependency: perl(Term::ReadKey) for package: git-1.8.2.1-1.el5.x86_64 --> Processing Dependency: perl(Git) for package: git-1.8.2.1-1.el5.x86_64 --> Processing Dependency: perl(Error) for package: git-1.8.2.1-1.el5.x86_64 --> Processing Dependency: libssl.so.6()(64bit) for package: git-1.8.2.1-1.el5.x86_64 --> Processing Dependency: libexpat.so.0()(64bit) for package: git-1.8.2.1-1.el5.x86_64 --> Processing Dependency: libcurl.so.3()(64bit) for package: git-1.8.2.1-1.el5.x86_64 --> Processing Dependency: libcrypto.so.6()(64bit) for package: git-1.8.2.1-1.el5.x86_64 --> Running transaction check ---> Package git.x86_64 0:1.8.2.1-1.el5 will be installed --> Processing Dependency: libssl.so.6()(64bit) for package: git-1.8.2.1-1.el5.x86_64 --> Processing Dependency: libexpat.so.0()(64bit) for package: git-1.8.2.1-1.el5.x86_64 --> Processing Dependency: libcurl.so.3()(64bit) for package: git-1.8.2.1-1.el5.x86_64 --> Processing Dependency: libcrypto.so.6()(64bit) for package: git-1.8.2.1-1.el5.x86_64 ---> Package perl-Error.noarch 1:0.17010-1.el5 will be installed --> Processing Dependency: perl(:MODULE_COMPAT_5.8.8) for package: 1:perl-Error-0.17010-1.el5.noarch ---> Package perl-Git.x86_64 0:1.8.2.1-1.el5 will be installed --> Processing Dependency: perl(:MODULE_COMPAT_5.8.8) for package: perl-Git-1.8.2.1-1.el5.x86_64 ---> Package perl-TermReadKey.x86_64 0:2.30-4.el5 will be installed --> Processing Dependency: perl(:MODULE_COMPAT_5.8.8) for package: perl-TermReadKey-2.30-4.el5.x86_64 --> Finished Dependency Resolution Error: Package: git-1.8.2.1-1.el5.x86_64 (epel) Requires: libssl.so.6()(64bit) Error: Package: git-1.8.2.1-1.el5.x86_64 (epel) Requires: libexpat.so.0()(64bit) Error: Package: perl-Git-1.8.2.1-1.el5.x86_64 (epel) Requires: perl(:MODULE_COMPAT_5.8.8) Error: Package: git-1.8.2.1-1.el5.x86_64 (epel) Requires: libcrypto.so.6()(64bit) Error: Package: perl-TermReadKey-2.30-4.el5.x86_64 (epel) Requires: perl(:MODULE_COMPAT_5.8.8) Error: Package: 1:perl-Error-0.17010-1.el5.noarch (epel) Requires: perl(:MODULE_COMPAT_5.8.8) Error: Package: git-1.8.2.1-1.el5.x86_64 (epel) Requires: libcurl.so.3()(64bit) You could try using --skip-broken to work around the problem You could try running: rpm -Va --nofiles --nodigest The command yum repolist Loaded plugins: product-id, refresh-packagekit, security, subscription-manager Updating certificate-based repositories. Unable to read consumer identity repo id repo name status epel Extra Packages for Enterprise Linux 5 - x86_64 7,351 rpmforge RHEL 6Server - RPMforge.net - dag 11,275 repolist: 18,626 Please help me install and resolve these missing dependencies uname --kernel-release 2.6.32-279.el6.x86_64
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 installation. In looking at a CentOS 5 installation I have here I have the following repositories: $ yum repolist Loaded plugins: fastestmirror repo id repo name status base CentOS-5 - Base 3,641 convirt ConVirt repository 4 convirt-dep ConVirt Dependencies 7 elrepo ELRepo.org Community Enterprise Linux Repository - el5 412 extras CentOS-5 - Extras 270 rpmforge RHEL 5 - RPMforge.net - dag 11,275 updates CentOS-5 - Updates 447 repolist: 16,056 See what versions of git I have outside of RPMForge: $ sudo yum --disablerepo=rpmforge list all git* Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirror.nexcess.net * elrepo: elrepo.org * extras: centos.mirrors.tds.net * updates: mirrors.einstein.yu.edu Installed Packages git.x86_64 1.7.10.4-1.el5.rf installed The above shows that if I disable RPMForge, the only version of git available for my mix of repos is the one coming from RPMForge, and the latest version is 1.7. Given this It would appear that you're mixing a package from CentOS 6, would be my guess. References Is it stable to use epel and rpmforge in the same time? Installing RPMforge
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 seems not to be updated correctly. What am I missing?
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 of the project, it's often easier to update software like this using your system's package manager. On macOS, the base system uses an older git version (2.37.1), which will unlikely change soon. Instead, I suggest you use the Homebrew package manager to install the latest version of git. There is no issue with having git installed in two separate locations on the same system. When setting up the Homebrew package manager, it will ensure that its versions of tools get priority over the base system's versions of the same tools.
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. This succeeds: root@server:/src# ssh -T [email protected] logged in as XXXX. This fails: root@server:/src# sudo ssh -T [email protected] Permission denied (publickey). Permissions are apparently correct: ls -la ~/.ssh total 32 drwx------ 2 root root 4096 Jun 2 12:18 . drwx------ 12 root root 4096 Jun 2 12:10 .. -rw------- 1 root root 550 Jun 1 16:31 authorized_keys -r-------- 1 root root 83 Jun 2 12:18 config -rw------- 1 root root 134 Jun 1 18:18 environment -rw------- 1 root root 1679 May 26 2015 id_rsa -rw-r--r-- 1 root root 393 Aug 3 2014 id_rsa.pub -rw-r--r-- 1 root root 3984 Jun 2 10:19 known_hosts Adding -v to the failing command shows all good up to the end, where there's no error until the failure: ... debug1: Authentications that can continue: publickey debug1: Next authentication method: publickey debug1: Offering RSA public key: /root/.ssh/id_rsa debug1: Server accepts key: pkalg ssh-rsa blen 279 debug1: key_parse_private2: missing begin marker debug1: read PEM private key done: type RSA debug1: Authentications that can continue: publickey debug1: No more authentication methods to try. Permission denied (publickey). I have searched and found only things related to permissions, but nothing explaining about sudo failing when running with root.
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 "solution" was to just remove the public key file.
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 access rights and goes like so: #!/bin/sh cd /home/pi/code /usr/bin/sudo -u pi -H /usr/bin/git pull origin master /usr/bin/sudo -u pi -H /home/pi/.nvm/v0.11.11/bin/forever start /home/pi/code/server.js Forever starts the server.js on reboot, no problem, but the repo never gets updated. If I run the script using sh /home/pi/code/script.sh it triggers git pull correctly... I initially set up an alias for git pull to be git up like it is recommended, but figured it might be my problem and I went back to the simplest version I could. Still no success. Any input is welcome. EDIT: the output of the crontab indicates connectivity issue: Could not resolve host: bitbucket.org how can I wait for network to be setup before I run the script?
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 - network interface might be down..." sleep 1 done cd /home/pi/code && /usr/bin/sudo -u pi -H git checkout master && /usr/bin/sudo -u pi -H git up /usr/bin/sudo -u pi -H /home/pi/.nvm/v0.11.11/bin/forever start /home/pi/code/server.js
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. When I tried to push it to Github (using my github account) git add myfile.php git commit -m "my first commit" git push origin mybranch I get this error : fatal: Out of memory, malloc failed I don't understand what this mean. The total size of the files I tried to push is 156Ko. Moreover the total size of the project is only 10,9Mo. I tried to reboot the server but the same happen. When I run free on the server I get : total used free shared buffers cached Mem: 505312 239532 265780 0 51576 71580 -/+ buffers/cache: 116376 388936 Swap: 0 0 0 My coworkers never had this problem before, even on the same test server. Can someone highlight me on the reason of this error and a possible workaround? Thanks in advance.
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 to match against. hello sitaram, this is gitolite v2.1-29-g5a125fa running on git 1.7.4.4 the gitolite config gives you the following access: R SecureBrowse R W anu-wsd R W entrans @R W git-notes @R W gitolite R W gitolite-admin R W indic_web_input @C R W private/sitaram/[\w.-]+ R W proxy @C @R W public/sitaram/[\w.-]+ @R_ @W_ testing R W vic This should output: SecureBrowse anu-wsd entrans git-notes gitolite gitolite-admin indic_web_input proxy testing vkc Currently I'm trying to put this in a shell script, so it would be usable for others. My current approach is a grep command, which looks like the following: grep -Eio "([A-Za-z0-9_-]+)$" gitolite-info-output However, this also captures the 4 at the end of the first line. I've been trying several approaches, but I can't seem to exclude that properly, without including or excluding other things. Doing this OS X 10.10.3.
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 anything matched up to this point". Combined with -o, we can search for lines starting with 0 or more spaces or @ (^[ @]*), then an R, then 0 or more characters until another space. All this is discarded because of the \K so only the last word is printed. If you don't have GNU grep (on OSX, for example), you can do something like this: $ grep -E '^[ @]*R' gitolite-info-output | awk '{print $NF}' SecureBrowse anu-wsd entrans git-notes gitolite gitolite-admin indic_web_input proxy testing vic Or do the whole thing in awk: $ awk '/^[ @]*R/{print $NF}' gitolite-info-output SecureBrowse anu-wsd entrans git-notes gitolite gitolite-admin indic_web_input proxy testing vic Or Perl: $ perl -nle '/^[ @]*R.*\s(.*)/ && print $1' gitolite-info-output SecureBrowse anu-wsd entrans git-notes gitolite gitolite-admin indic_web_input proxy testing vic
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). But I get this instead: fatal: ambiguous argument '%(s)': unknown revision or path not in the working tree. Use '--' to separate paths from revisions Presumably that has something to do with the quoting and spaces, but I'm far from fluent in bash. Any help?
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 guess is another function you created.
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), password varchar(255)); create table repository (id int primary key auto_increment, name varchar(255)); create table repository_member(id int primary key auto_increment, user_id int, repository_id int); Pretty straightforward, right? I've used Gitosis (ironically hosted on GitHub) in the past, but something which uses a database would be a lot better than editing and committing changes to a couple text files on the hard drive. Is there another service which would make it easier to host tons of Git repositories and be able to heavily integrate it into a web application like GitHub does?
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 tar cvf gitrepo.tar gitrepo/ Now, this works at first glance, but if i extract it somewhere, a couple of oddities appear, such as: the git config (the one in .git/config) seems to not be the same one that was put in the tar, but an "older" version. eg: if i edit the config and tar it, then extract it, the config won't have the latest change for whatever reason... Beside that, everything else seems to work, though i didn't check if other files in the .git folder had similar oddities as the config file. Using git bundle The two command i tried were: git bundle create repo.bundle and git bundle create repo.bundle --all The first command work on first glance, but i then noticed it didn't had all the branch, given i didn't use the --all flag. The second command work on first glance (again), but, if i git clone said bundle, it end up not containing all the files that are committed in the non-bundled/original local repo... I thought that the "missing files" were in .git, so i looked for the biggest file there, and found one in .git/objects/pack...so i unpacked it using the following command: cd "$@"/.git/objects/pack ; mkdir ~/SAMPLE; mv *.pack ~/SAMPLE; git unpack-objects < ~/SAMPLE/*.pack; rm -rf ~/SAMPLE $@ being the name of the local repo that was cloned from the git bundle. I didn't solve the above issue but i did notice that some of the commit history was restored, albeit with files still missing from the original repo. So I'm confused at to how correctly backing up my local git repo (preferably in a single file) while still retaining latest change on file and without missing files? (as in, all commit history, branch, etc)
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 directly to that commit on Github? This would make my life much easier. :)
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 $parent add . git -C $parent commit -m "committed by script" 1>/dev/null 2>/dev/null if [[ $? == 128 ]]; then git -C $parent commit -m "commited by script" 1>/dev/null 2>/dev/null git -C $parent push if [[ $? == 1 ]]; then git -C $parent pull git -C $parent push fi else git -C $parent push if [[ $? == 1 ]]; then git -C $parent pull git -C $parent push fi fi ) & fi done wait } However, when I run it, git asks for username: Username for 'https://github.com': Here are the tests I have done, to make sure git has access to GitHub: ssh -T [email protected] => successful sudo -i + ssh -T [email protected] => successful I go into a git repository, and I change something, and I manaully add + commit + push => successful I go to my home, and add + commit + push from another repository using -C another_git_repo_path => successfull Then why it does not work when I run it from inside a script?
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 like: git remote set-url origin [email protected]:UserName/Repo.git Or in .git/config file you can change he line url = https://github.com/ to url = [email protected]:....: $> cat .git/config [core] repositoryformatversion = 0 filemode = true bare = false logallrefupdates = true [remote "origin"] url = [email protected]:UserName/Repo.git # edited line fetch = +refs/heads/*:refs/remotes/origin/*
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 and delete the line having VARIABLE= curl: (18) transfer closed with outstanding read data remaining My POST-request is generated by curl (the post-data is just for testing, it doesn't get used in the actual script): curl -D - -H "Connection: close" -H "Content-Type: application/json" -d '{ "repository": { "name": "webhook-test", "git_url": "git://github.com/bng44270/webhook-test.git", "ssh_url": "[email protected]:bng44270/webhook-test.git", "clone_url": "https://github.com/bng44270/webhook-test.git" }}' http://10.0.0.2/cgi-bin/clone.cgi --verbose My vhost config file: ScriptAlias "/cgi-bin" "/opt/hooks/cgi-bin" DocumentRoot /opt/hooks/html <Directory /opt/hooks> Options Indexes FollowSymLinks AllowOverride All Require all granted </Directory> </VirtualHost> My script running: #!/bin/bash /sbin/runuser -l gogsjail -c '/usr/bin/git --git-dir /home/gogsjail/gogs-repositories/admin/upstream.git fetch --prune >/dev/null 2>&1' >/dev/null 2>&1 # VARIABLE=$(cat -) echo "Content-type: text/json" echo "" echo '{"result":"success"}' and finally, the output from curl: * Expire in 0 ms for 6 (transfer 0x563f98984f90) * Trying 10.0.0.2... * TCP_NODELAY set * Expire in 200 ms for 4 (transfer 0x563f98984f90) * Connected to 10.0.0.2 (10.0.0.2) port 80 (#0) > POST /cgi-bin/clone.cgi HTTP/1.1 > Host: 10.0.0.2 > User-Agent: curl/7.64.0 > Accept: */* > Connection: close > Content-Type: application/json > Content-Length: 230 > * upload completely sent off: 230 out of 230 bytes < HTTP/1.1 200 OK HTTP/1.1 200 OK < Date: Mon, 08 Feb 2021 12:55:42 GMT Date: Mon, 08 Feb 2021 12:55:42 GMT < Server: Apache/2.4.38 (Debian) Server: Apache/2.4.38 (Debian) < Connection: close Connection: close < Transfer-Encoding: chunked Transfer-Encoding: chunked < Content-Type: text/json Content-Type: text/json < {"result":"success"} * transfer closed with outstanding read data remaining * Closing connection 0 curl: (18) transfer closed with outstanding read data remaining If I run with VARIABLE=$(cat -) before echo-calls I get * Expire in 0 ms for 6 (transfer 0x55ea56355f90) * Trying 10.0.0.2... * TCP_NODELAY set * Expire in 200 ms for 4 (transfer 0x55ea56355f90) * Connected to 10.0.0.2 (10.0.0.2) port 80 (#0) > POST /cgi-bin/clone.cgi HTTP/1.1 > Host: 10.0.0.2 > User-Agent: curl/7.64.0 > Accept: */* > Connection: close > Content-Type: application/json > Content-Length: 244 > * upload completely sent off: 244 out of 244 bytes < HTTP/1.1 200 OK < Date: Mon, 08 Feb 2021 13:35:28 GMT < Server: Apache/2.4.38 (Debian) < Connection: close < Transfer-Encoding: chunked < Content-Type: text/json < {"result":"success"} * Closing connection 0 Can someone nudge me in the correct direction?
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. When the cgi exits and closes the pipe, apache's select() sees an exception on read, due to the eof, and an exception on write. If the cgi does not read the POST data from apache, apache sees the pending write getting an ioerror, and so might assume the cgi is badly behaved, and just close the client connection without further cleanup. Since the cgi does not put out a content-length header, apache cannot determine the length of the reply, so puts out a Transfer-Encoding: chunked header. This protocol surrounds each write in the reply by a mini-heading consisting of the length of the following write. The protocol needs to be cleanly terminated by sending a write length of 0 (0\r\n). Presumably, this last part of the protocol is what is missing, and is the cause of curl's complaint. The chunked protocol is not exposed by curl, but you might see it with --raw, or by using strace().
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). It will also delete any other ignored file or directory. This lists all files and directories starting from the current directory, checks whether they’re ignored (even if they’re committed), and delete them, regardless of whether they’re committed, untracked etc. This works with any .gitignore files in the tree (or even elsewhere in your git configuration). Follow up by committing the changes and pushing them; since the changes are a new commit, you won’t need to force-push anything. Rewriting history to remove all references to supposedly ignored files is a slightly more involved task.
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); echo "$wc $sha" >> /tmp/script.out done cat /tmp/script.out | grep -v ^$ | sort | head -1 | cut -d' ' -f 2
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 relevant hunk: $courier: "courier new", courier, freemono, "nimbus mono l", "liberation mono", monospace; - -$monaco: monaco, "lucida console", "dejavu sans mono", - "bitstream vera sans mono", "liberation mono", - monospace; \ No newline at end of file + +$monaco: monaco, "lucida console", "dejavu sans mono", + "bitstream vera sans mono", "liberation mono", + monospace; + +h1 { + font-size: 2em; +} [snip] I'd like to commit everything up to h1 as a whitespace fix, and everything after in a separate commit.
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 you don't want to be included in the add and save it then.
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 all jobs of upstart $ initctl list indicator-application start/running, process 2364 unicast-local-avahi stop/waiting update-notifier-crash stop/waiting upstart-udev-bridge start/running, process 1773 update-notifier-hp-firmware stop/waiting xsession-init stop/waiting dbus start/running, process 1774 no-pinentry-gnome3 stop/waiting update-notifier-cds stop/waiting gnome-keyring-ssh stop/waiting gnome-session (Unity) start/running, process 2007 ssh-agent stop/waiting unity7 start/running, process 2132 upstart-dbus-session-bridge start/running, process 1812 gpg-agent start/running indicator-messages start/running, process 2343 logrotate stop/waiting indicator-bluetooth start/running, process 2344 unity-panel-service start/running, process 2009 hud start/running, process 1969 im-config start/running unity-gtk-module stop/waiting session-migration stop/waiting upstart-dbus-system-bridge start/running, process 1811 at-spi2-registryd start/running, process 1999 indicator-power start/running, process 2345 update-notifier-release stop/waiting indicator-datetime start/running, process 2346 indicator-keyboard start/running, process 2347 unity-settings-daemon start/running, process 1971 indicator-sound start/running, process 2348 upstart-file-bridge start/running, process 1817 bamfdaemon start/running, process 1828 gnome-keyring stop/waiting window-stack-bridge start/running, process 1786 indicator-printers start/running, process 2349 re-exec stop/waiting upstart-event-bridge stop/waiting unity-panel-service-lockscreen stop/waiting indicator-session start/running, process 2350 and also $ initctl status unity7 start/running, process 2132 I didn't see anything that related to these git processes. Can anyone give me some hints of what's going wrong and how should I locate my problem? Thanks.
@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 not there would be git add **/somename.java. I have also tried adding more asterisks, slashes, dollar sign followed by a quote, etc.
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, use a function instead of an alias. Here's a zsh version which is pretty versatile. function ga { git add **/$^~@(.N) } alias ga='noglob ga' Here's how it works for ga foo* bar: The alias ga expands to noglob ga. Thanks to the noglob precommand modifier, noglob ga foo* bar does not expand the wildcard in foo*, and instead passes foo* literally as an argument to ga. Since ga (the one in noglob ga …) isn't the first word in the command, it is not looked up as an alias, and therefore it refers to the function, which is called with the arguments foo* and bar. $^~@ uses the ${^spec} and ${~spec} parameter expansion forms. The modifier ^ causes **/ to be prepended to each element of the array $@, resulting in **/foo* and **/bar. Without this modifier, **/$@ would expand to **/foo* and bar. $~@ causes the wildcard characters in the arguments to be expanded now. This way, the pattern foo* is not expanded by itself: what's expanded is **/foo*, so this matches things like sub/dir/foobar. The . glob qualifier causes only regular files to be matched. Make it -. to also match symbolic links to regular files, or @. to match all symbolic links in addition to regular files. The N glob qualifier causes patterns that match nothing to be omitted. Don't put (N) if you prefer to have an error if one of the patterns doesn't match anything. About the only nice thing that's missing here is completion, which is doable but I think not worth the trouble here. In bash, you can't have it as nice. There's no way to prevent wildcards from being expanded immediately, so ga foo* will be equivalent to ga foo1 foo2 if the directory content is .git … foo1 foo2 subdir subdir/foobar which will miss subdir/foobar. In bash, since you need to quote wildcards in arguments, you might as well rely on Git's own pattern matching in a pathspec. Note in particular that * matches directory separators, i.e. it has the shell ** behavior built in. function ga { local x for x in "$@"; do git add "*/$x" done } ga 'foo*' bar On a final note, if you keep your .gitignore up-to-date and commit often, you'll rarely need anything other than git add ..
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 $ mkdir a $ mkdir b $ mkdir c $ cd a $ mkdir .git $ cd .. $ cd b $ touch .git $ cd .. $ cd c $ mkdir c1 $ mkdir c2 $ cd.. $ find . -type d \( \( ! -name . -exec [ -e {}/.git ] \; -prune \) -o \( \( \ -name .git\ -o -name .vscode\ -o -name node_modules\ -o -name Image\ -o -name Rendered\ -o -name iNotebook\ -o -name GeneratedTest\ -o -name GeneratedOutput\ \) -prune \) -o -print \) | sort Expected Results . ./a ./c ./c/c1 ./c/c2
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 command doesn’t search inside the main .git directory of a repository) -print prints anything which isn’t caught by the above. To only match directories, add -type d, either just before -print, or (to save time processing files): find . -type d \( \( -exec [ -f {}/.git ] \; -prune \) -o \( -name .git -prune \) -o -print \) This also works when run this on a directory other than ., by changing the find start path: find /some/other/path -type d \( \( -exec [ -f {}/.git ] \; -prune \) -o \( -name .git -prune \) -o -print \)
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. I am sure there would be some ways like - Find the author who has done the most commits in a project. find the authors who have done the most commits in a descending manner. Find committers who have done the most commits in a project and things like that. It could make for some interesting analysis of a project's state per se. Do people have any idea what could be done in the above instance? I am on Debian buster.
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 line (tail -n 1) to find the most prolific, reverse the sort (sort -nr) for descending, or whatever other processing you like.
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 the next command I use --force to change permissions and --zero to overwrite with zeros after shredding. The default shredding method is to overwrite with random data three times (-n3). I also want to remove the files afterwards. According to man shred, --remove=wipesync (the default, when --remove is used) only operates on directories, but this seems to slow me down even when I operate only on files. Compare (each time I reinitialized the git repo): $ time find ~/tmp/.git -type f | xargs shred --force --zero --remove=wipesync real 8m18.626s user 0m0.097s sys 0m1.113s $ time find ~/tmp/.git -type f | xargs shred --force --zero --remove=wipe real 0m45.224s user 0m0.057s sys 0m0.473s $ time find ~/tmp/.git -type f | xargs shred --force --zero -n1 --remove=wipe real 0m33.605s user 0m0.030s sys 0m0.110s Is there a better way to do it? EDIT: Yes, encryption is the key. I'm now just adding two more benchmarks using -n0. time find ~/tmp/.git -type f | xargs shred --force --zero -n0 --remove=wipe real 0m32.907s user 0m0.020s sys 0m0.333s Using 64 parallel shreds: time find ~/tmp/.git -type f | parallel -j64 shred --force --zero -n0 --remove=wipe real 0m3.257s user 0m1.067s sys 0m1.043s
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 theory) to recover overwritten data. This is no longer the case with modern disk technologies: overwriting just once with zeroes is just as good — but the idea of multiple random passes stayed around well after it had become obsolete. See https://security.stackexchange.com/questions/10464/why-is-writing-zeros-or-random-data-over-a-hard-drive-multiple-times-better-th On the other hand, shred utterly fails in wiping sensitive information, because it only wipes the data in the files that it is told to erase. Any data that was stored in previously erased files may still be recoverable by accessing the disk directly instead of via the filesystem. Data from a git tree may not be very easy to reconstruct; nevertheless this is a realistic threat. To be able to quickly wipe some data, encrypt it. You can use ecryptfs (home directory encryption), or encfs (encryption of a directory tree), or dm-crypt (whole-partition encryption), or any other method. To wipe the data, just wipe the key. See also How can I be sure that a directory or file is actually deleted?
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 to install git-all, can I install only git? What is the difference between these two packages? I think its worth mentioning that I'm using debian 10 'buster' and I do have some non-free firmware since my wireless card required it, although I don't think that this has nothing to do with my problem... Thanks for the help in advance, I'm 17 years old completely new to this technical world, can't really code anything but a "hello world". I previously asked about this in stack overflow but kaylum explained to me that stack overflow is destined only to programming related questions, so I wanted to express my gratitude to him for showing me these site, so... Thanks dude! I did revise the help page from this site, stack overflow and super user, and I think it's plausible for me to ask here, even so if it's not fitting for this site as well, do let me know... Right below here is the output of sudo apt install git-all Reading package lists... Done Building dependency tree Reading state information... Done The following packages were automatically installed and are no longer required: accountsservice apg appstream apt-config-icons argyll argyll-ref bolt colord-data cracklib-runtime desktop-file-utils dnsmasq-base exfat-fuse exfat-utils fwupd fwupd-amd64-signed gdisk gir1.2-accountsservice-1.0 gir1.2-clutter-gst-3.0 gir1.2-dazzle-1.0 gir1.2-gck-1 gir1.2-gcr-3 gir1.2-gdm-1.0 gir1.2-gmenu-3.0 gir1.2-gnomebluetooth-1.0 gir1.2-grilo-0.3 gir1.2-ibus-1.0 gir1.2-mediaart-2.0 gir1.2-mutter-3 gir1.2-nm-1.0 gir1.2-nma-1.0 gir1.2-packagekitglib-1.0 gir1.2-polkit-1.0 gir1.2-rsvg-2.0 gir1.2-upowerglib-1.0 gnome-control-center-data gnome-session-bin gnome-session-common gnome-shell-common gnome-software-common gvfs-common gvfs-libs hyphen-en-us javascript-common libaccountsservice0 libappstream-glib8 libappstream4 libatasmart4 libblockdev-crypto2 libblockdev-fs2 libblockdev-loop2 libblockdev-part-err2 libblockdev-part2 libblockdev-swap2 libblockdev-utils2 libblockdev2 libcdio-cdda2 libcdio-paranoia2 libcolord-gtk1 libcolorhug2 libcrack2 libfwupd2 libgcab-1.0-0 libgdm1 libgnome-menu-3-0 libibus-1.0-5 libmusicbrainz5-2 libmusicbrainz5cc2v5 libndp0 libnfs12 libnm0 libnma0 libnss-myhostname libntfs-3g883 libparted-fs-resize0 libpolkit-agent-1-0 libpolkit-backend-1-0 libpwquality-common libpwquality1 libreoffice-help-common libreoffice-help-en-us libsmbios-c2 libteamdctl0 libtss2-esys0 libtss2-udev libudisks2-0 libvolume-key1 libxmlb1 mobile-broadband-provider-info mousetweaks mythes-en-us nautilus-data node-normalize.css ntfs-3g python3-distro-info python3-software-properties realmd software-properties-common software-properties-gtk switcheroo-control tpm2-abrmd tpm2-tools unattended-upgrades xwayland Use 'sudo apt autoremove' to remove them. The following additional packages will be installed: apache2 apache2-data apache2-utils cvs cvsps elpa-async elpa-dash elpa-ghub elpa-git-commit elpa-graphql elpa-let-alist elpa-magit elpa-magit-popup elpa-treepy elpa-with-editor emacs emacs-bin-common emacs-common emacs-el emacs-gtk exim4-base exim4-config exim4-daemon-light git git-cvs git-daemon-run git-doc git-el git-email git-gui git-man git-mediawiki git-svn gitk gitweb guile-2.2-libs imagemagick-6-common initscripts insserv install-info libalgorithm-c3-perl libb-hooks-endofscope-perl libb-hooks-op-check-perl libcgi-fast-perl libcgi-pm-perl libclass-c3-perl libclass-c3-xs-perl libclass-data-inheritable-perl libclass-factory-util-perl libclass-inspector-perl libclass-method-modifiers-perl libclass-singleton-perl libclass-xsaccessor-perl libcommon-sense-perl libdata-optlist-perl libdatetime-format-builder-perl libdatetime-format-iso8601-perl libdatetime-format-strptime-perl libdatetime-locale-perl libdatetime-perl libdatetime-timezone-perl libdbd-sqlite3-perl libdbi-perl libdevel-callchecker-perl libdevel-caller-perl libdevel-lexalias-perl libdevel-stacktrace-perl libdigest-bubblebabble-perl libdigest-hmac-perl libdynaloader-functions-perl libemail-valid-perl liberror-perl libeval-closure-perl libexception-class-perl libfcgi-perl libfile-sharedir-perl libgc1c2 libgnutls-dane0 libgsasl7 libheif1 libjson-perl libjson-xs-perl libkyotocabinet16v5 liblqr-1-0 liblzo2-2 libm17n-0 libmagickcore-6.q16-6 libmagickwand-6.q16-6 libmailutils5 libmediawiki-api-perl libmodule-implementation-perl libmodule-runtime-perl libmro-compat-perl libnamespace-autoclean-perl libnamespace-clean-perl libnet-dns-perl libnet-dns-sec-perl libnet-domain-tld-perl libnet-ip-perl libnet-libidn-perl libntlm0 libotf0 libpackage-stash-perl libpackage-stash-xs-perl libpadwalker-perl libparams-classify-perl libparams-util-perl libparams-validate-perl libparams-validationcompiler-perl libreadonly-perl libref-util-perl libref-util-xs-perl librole-tiny-perl libserf-1-1 libspecio-perl libsub-exporter-perl libsub-exporter-progressive-perl libsub-identify-perl libsub-install-perl libsub-name-perl libsub-quote-perl libsvn-perl libsvn1 libtcl8.6 libterm-readkey-perl libtk8.6 libtypes-serialiser-perl libunbound8 libutf8proc2 libvariable-magic-perl libyaml-libyaml-perl libyaml-perl m17n-db mailutils mailutils-common runit runit-helper runit-sysv startpar sysuser-helper sysv-rc sysvinit-core tcl tcl8.6 tk tk8.6 Suggested packages: apache2-doc apache2-suexec-pristine | apache2-suexec-custom mksh rcs emacs-common-non-dfsg exim4-doc-html | exim4-doc-info eximon4 spf-tools-perl swaks meld mediawiki subversion bootchart2 libclone-perl libmldbm-perl libnet-daemon-perl libsql-statement-perl m17n-docs libmagickcore-6.q16-6-extra libscalar-number-perl libtest-fatal-perl libyaml-shell-perl gawk mailutils-mh mailutils-doc bootlogd tcl-tclreadline The following packages will be REMOVED: chrome-gnome-shell colord dbus-user-session gdm3 gnome gnome-color-manager gnome-control-center gnome-core gnome-disk-utility gnome-music gnome-session gnome-settings-daemon gnome-shell gnome-shell-extensions gnome-software gnome-sushi gnome-tweaks gstreamer1.0-packagekit gvfs gvfs-backends gvfs-daemons gvfs-fuse libpam-systemd nautilus nautilus-extension-brasero network-manager network-manager-gnome packagekit packagekit-tools policykit-1 rtkit systemd-sysv task-gnome-desktop udisks2 The following NEW packages will be installed: apache2 apache2-data apache2-utils cvs cvsps elpa-async elpa-dash elpa-ghub elpa-git-commit elpa-graphql elpa-let-alist elpa-magit elpa-magit-popup elpa-treepy elpa-with-editor emacs emacs-bin-common emacs-common emacs-el emacs-gtk exim4-base exim4-config exim4-daemon-light git git-all git-cvs git-daemon-run git-doc git-el git-email git-gui git-man git-mediawiki git-svn gitk gitweb guile-2.2-libs imagemagick-6-common initscripts insserv install-info libalgorithm-c3-perl libb-hooks-endofscope-perl libb-hooks-op-check-perl libcgi-fast-perl libcgi-pm-perl libclass-c3-perl libclass-c3-xs-perl libclass-data-inheritable-perl libclass-factory-util-perl libclass-inspector-perl libclass-method-modifiers-perl libclass-singleton-perl libclass-xsaccessor-perl libcommon-sense-perl libdata-optlist-perl libdatetime-format-builder-perl libdatetime-format-iso8601-perl libdatetime-format-strptime-perl libdatetime-locale-perl libdatetime-perl libdatetime-timezone-perl libdbd-sqlite3-perl libdbi-perl libdevel-callchecker-perl libdevel-caller-perl libdevel-lexalias-perl libdevel-stacktrace-perl libdigest-bubblebabble-perl libdigest-hmac-perl libdynaloader-functions-perl libemail-valid-perl liberror-perl libeval-closure-perl libexception-class-perl libfcgi-perl libfile-sharedir-perl libgc1c2 libgnutls-dane0 libgsasl7 libheif1 libjson-perl libjson-xs-perl libkyotocabinet16v5 liblqr-1-0 liblzo2-2 libm17n-0 libmagickcore-6.q16-6 libmagickwand-6.q16-6 libmailutils5 libmediawiki-api-perl libmodule-implementation-perl libmodule-runtime-perl libmro-compat-perl libnamespace-autoclean-perl libnamespace-clean-perl libnet-dns-perl libnet-dns-sec-perl libnet-domain-tld-perl libnet-ip-perl libnet-libidn-perl libntlm0 libotf0 libpackage-stash-perl libpackage-stash-xs-perl libpadwalker-perl libparams-classify-perl libparams-util-perl libparams-validate-perl libparams-validationcompiler-perl libreadonly-perl libref-util-perl libref-util-xs-perl librole-tiny-perl libserf-1-1 libspecio-perl libsub-exporter-perl libsub-exporter-progressive-perl libsub-identify-perl libsub-install-perl libsub-name-perl libsub-quote-perl libsvn-perl libsvn1 libtcl8.6 libterm-readkey-perl libtk8.6 libtypes-serialiser-perl libunbound8 libutf8proc2 libvariable-magic-perl libyaml-libyaml-perl libyaml-perl m17n-db mailutils mailutils-common runit runit-helper runit-sysv startpar sysuser-helper sysv-rc sysvinit-core tcl tcl8.6 tk tk8.6 0 upgraded, 147 newly installed, 34 to remove and 0 not upgraded. Need to get 80.9 MB of archives. After this operation, 261 MB of additional disk space will be used. Do you want to continue? [Y/n] n Abort. **EDIT: ** Ok, I used the --dry-run switch as ajgringo619 suggested me, and found out while reading it slower that it wasn't removing only the gnome packages, but packages like nautilus, network-manager... and many others that I don't even know the purpose, saying that those packages are no longer required, even though I think network-manager is required when you're downloading something. As to what I was doing before this: Nothing, I mean, the first time I ran sudo apt install git-all -y I broke my system and reinstalled it because I'm not knowledgeable enough to repair it on my on, and after that, before installing anything, any non-free firmware I ran the same command and broke it for the second time, after reinstalling it the second time I didn't avoided the git-all package, installed vscode, zeal, removed games that came with the system, changed background and when I thought about installing git-all I removed the -y thing and actually read the output. Here I am now, asking for help. This are the packages that it wants to remove: Remv chrome-gnome-shell [10.1-5] Remv gnome [1:3.30+1] Remv task-gnome-desktop [3.53] Remv gnome-core [1:3.30+1] Remv gnome-control-center [1:3.30.3-2~deb10u1] Remv gnome-color-manager [3.30.0-2] Remv colord [1.4.3-4] Remv network-manager-gnome [1.8.20-1.1] Remv dbus-user-session [1.12.20-0+deb10u1] Remv gdm3 [3.30.2-3] Remv gnome-disk-utility [3.30.2-3] Remv gnome-music [3.30.2-1] Remv gnome-session [3.30.1-2] Remv gnome-tweaks [3.30.2-1] Remv gnome-shell-extensions [3.30.1-1] Remv gnome-settings-daemon [3.30.2-3] [gnome-shell:amd64 ] Remv gnome-shell [3.30.2-11~deb10u2] Remv gnome-software [3.30.6-5] Remv gnome-sushi [3.30.0-2] Remv gstreamer1.0-packagekit [1.1.12-5] Remv gvfs-backends [1.38.1-5] Remv nautilus [3.30.5-2] Remv gvfs [1.38.1-5] [gvfs-fuse:amd64 nautilus-extension-brasero:amd64 ] Remv gvfs-daemons [1.38.1-5] [gvfs-fuse:amd64 nautilus-extension-brasero:amd64 ] Remv gvfs-fuse [1.38.1-5] [nautilus-extension-brasero:amd64 ] Remv udisks2 [2.8.1-4] [nautilus-extension-brasero:amd64 ] Remv rtkit [0.11-6] [nautilus-extension-brasero:amd64 ] Remv policykit-1 [0.105-25] [network-manager:amd64 packagekit:amd64 nautilus-extension-brasero:amd64 ] Remv libpam-systemd [241-7~deb10u4] [network-manager:amd64 packagekit:amd64 nautilus-extension-brasero:amd64 ] Remv nautilus-extension-brasero [3.12.2-5] [network-manager:amd64 packagekit:amd64 ] Remv network-manager [1.14.6-2+deb10u1] [packagekit:amd64 ] Remv packagekit-tools [1.1.12-5] [packagekit:amd64 ] Remv packagekit [1.1.12-5]
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-daemon-run or git-daemon-sysvinit, but apt automatically chooses git-daemon-run for some reason: $ apt depends git-all git-all Залежності (Depends): git (>> 1:2.20.1) Залежності (Depends): git (<< 1:2.20.1-.) Залежності (Depends): git-doc Залежності (Depends): git-el Залежності (Depends): git-cvs Залежності (Depends): git-mediawiki Залежності (Depends): git-svn Залежності (Depends): git-email Залежності (Depends): git-gui Залежності (Depends): gitk Залежності (Depends): gitweb |Рекомендує (Recommends): git-daemon-run Рекомендує (Recommends): git-daemon-sysvinit According to the package description, which you can lookup with apt show git-daemon-run (emphasis mine): git-daemon, as provided by the git package, is a simple server for git repositories, ideally suited for read-only updates, i.e. pulling from git repositories through the network. This package provides a runit service for running git-daemon permanently. This configuration is simpler and more reliable than git-daemon-sysvinit, at a cost of being less familiar for administrators accustomed to sysvinit. git-daemon-run depends on runit, which recommends alternatively runit-sysv, runit-init, or runit-systemd. apt chooses runit-sysv for some reason. runit-sysv depends on sysvinit-core. This and runit-init conflict with systemd-sysv, which is already installed by default on Debian: $ apt depends sysvinit-core runit-init --installed sysvinit-core Залежності (Depends): debianutils (>= 4) Залежності (Depends): sysvinit-utils (>= 2.86.ds1-66) |Залежності (Depends): debconf (>= 0.5) cdebconf debconf Залежності (Depends): libc6 (>= 2.15) Залежності (Depends): libselinux1 (>= 1.32) Залежності (Depends): libsepol1 (>= 2.4) Конфлікти (Conflicts): systemd-sysv Заміняє (Replaces): systemd-sysv runit-init Залежності (Depends): libc6 (>= 2.4) Конфлікти (Conflicts): systemd-sysv Заміняє (Replaces): systemd-sysv So, to resolve your issue, you have to instruct apt to keep systemd-sysv when installing git-all: $ sudo apt-get install git-all systemd-sysv This time apt will choose runit-systemd and no packages should be removed.
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 the key is default id_rsa but not when the key is different. If I add it in bashrc then it does add the key and work when I log in, but not immediately from boot. How can I add an alternative SSH key than id_rsa for git to use, that can be instantiated before my git pull command in rc.local? Thanks
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 aws.apache HostName 1.2.3.4 User wwwdata IdentityFile ~/.ssh/aws.apache.key You can read more here
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 until I want to exit it?
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 use git gui install gitFull instead of git. Both packages actually come from the same Nix expression, but when using gitFull the expression is applied such that it includes support for git gui.
How to enable `git gui` in NixOS?