What does the option " -q" in git cli and this command do? - linux

I'm learning for Machine Learning and I'm analyzing about Siam Mask Tutorial in google colab.
I saw the code "-q", I don't know what the code means.
I looked it up but couldn't find it.
I'd be very grateful if you could help me.
I think that the code is one of Linux command option
!git clone -q --depth 1 {git_repo_url}
!sed -i "/torch/d" {project_name}/requirements.txt
!cd {project_name} && pip install -q -r requirements.txt
!cd {project_name} && bash make.sh
!pip install -q youtube-dl

The code is not about machine learning but clones a repository managed by the version control system git.
Git clone's help page tell you the -q option switches to quiet, as in non-verbous, command line output.
git clone -?
usage: git clone [<options>] [--] <repo> [<dir>]
-v, --verbose be more verbose
-q, --quiet be more quiet
--progress force progress reporting
-n, --no-checkout don't create a checkout
--bare create a bare repository
--mirror create a mirror repository (implies bare)
-l, --local to clone from a local repository
[...]
The second -q option in your example refers to pip becoming quit(er), as in less verbose, by reducing the loglevel with each q you add as a parameter (max. 3 are possible). This can be found by calling `pip install --help``` on your console. Excerpt:
-q, --quiet Give less output. Option is additive, and can be used up to 3 times (corresponding to WARNING, ERROR, and CRITICAL logging levels).
So, line by line your bash commands do the following:
clone repository to current prompt from {git_repo_url}
string operation in requirements.txt for dependency correction
change prompt to project directory and install all python dependencies of the project
change prompt to project directory and run the make script
install python package quietly
Generally for future reference: If you are unsure about what a command does, try using only that command with no parameters plus any variation of -?, -h or --help. On most unixoide shells this gives you a pretty helpful page of the command's purpose and all (or most) of its possible parameters. Make it a habit of always referring to this first, this is literally the developers themselves teaching you how to use their software.

Related

What causes git interactive to not be present when git is installed?

Running on Alpine Linux 3.10, I've installed the distribution's git package using apk.
In an existing checkout directory, when I try to launch git add's interactive mode:
$ git add -i
I get the error:
git: 'add--interactive' is not a git command. See 'git --help'.
The git add help indicates that -i is a valid option.
What is happening?
The interactive mode feature of git uses perl, and in many Linux distributions the perl-based parts of git are separated out into another package, so that the core functionality of git can be used without needing to install perl.
On Alpine, the git package just has this core functionality.
To get the missing functionality on Alpine, install the git-perl package.
$ sudo apk add git-perl
On RedHat Linux, you may need to add the perl-Git package:
$ sudo dnf install -y perl-Git

install atom on centos 7 without admin privileges

If it is possible could someone show me how to get the editor Atom working on CentOS Linux release 7.x. I'm working on a computing cluster so I don't have sudo privileges. The instructions here: https://github.com/atom/atom/blob/master/docs/build-instructions/linux.md
seem to require sudo privileges
How do I install it with these constraints?
In the link that you have shared, go to the Instructions section below openSuse instructions.
Step 1 is:
git clone https://github.com/atom/atom
cd atom
Run this step in your home directory.
After that run Step 2 and Step 3 as per the document:
git fetch -p
git checkout $(git describe --tags `git rev-list --tags --max-count=1`)
script/build
After that instead of Step 4, run:
script/grunt install --install-dir /home/<your-username>/bin/
This will install the application in your home directory which can be done without sudo privilege. You can add /home/<your-username>/bin at the end of your PATH variable and you should be able to use atom as usual.
All this is assuming that you have the requirements for atom already installed on the system, particularly node.js. If not, you will have to install node.js as well as per https://www.vultr.com/docs/installing-node-js-from-source-on-ubuntu-14-04
In this, instead of ./configure, run ./configure --prefix=/home/<your-username>

Installing Git version above 1.8.5 on Centos

Earlier today, I ran into problems moving git folders (Move Git folder containing submodules), and the recommendation was to use a newer git version above 1.8.5. Easy, I thought, but haven't been so lucky.
I've searched high and low, and the most recent version I could find in a yum repository is 1.8.3 (PUIAS_6_computational: puias.math.ias.edu).
I then looked for help installing by source (http://www.howtoforge.com/how-to-install-the-latest-git-version-on-centos and http://tecadmin.net/install-git-2-0-on-centos-rhel-fedora/ which are almost identical), however, git is only available to the root user, and it is my understanding both these tutorials shouldn't be installing in /usr/local/.
# cd git-2.0.4
# make prefix=/usr/local/git all
# make prefix=/usr/local/git install
# echo "export PATH=$PATH:/usr/local/git/bin" >> /etc/bashrc
# source /etc/bashrc
Please provide a means to use Git version greater than 1.8.5.
Try following this set of instructions:
https://www.digitalocean.com/community/tutorials/how-to-install-git-on-centos-7
Then, do this:
yum remove git
exit
# reopen an terminal
Using Docker you have two options:
If you don't want to install dependencies on your host you could build it with docker, you could try this: https://github.com/wood1986/docker-library/tree/master/git
Or a quick but far from ideal way, you could execute it on a docker container, so every time you run git a container is created, your command is executed and the container is automatically removed and a cleaned up is made.
First: sudo yum remove git
then: sudo vim /bin/git
with this:
#!/bin/bash
docker run -ti --rm -v ${HOME}:/root -v $(pwd):/git alpine/git $#
last: sudo chmod 775 /bin/git
and add .gitconfig with your name and email to your home
Check your version: git --version

unable to install git from source code

I am new to using git. So i first install git from terminal using apt-get but then i remove it as in ubuntu the version is very old.
After this i install git from source code which i download from https://code.google.com/p/git-core/downloads/list. Then these are the commands used by me
sudo apt-get install libcurl4-gnutls-dev libexpat1-dev gettext libz-dev libssl-dev build-essential
tar -zxf git-1.9.0.tar.gz
cd git-1.9.0/
make prefix=/usr/local all
sudo make prefix=/usr/local install
Then when i put these commands it is behaving in this manner.
~/git-1.9.0$ which git
/usr/local/bin/git
~/git-1.9.0$ git --version
bash: /usr/bin/git: No such file or directory
Your shell remembers where it found the executable file for commands you run, to save itself the trouble (and you the delays) of hunting them down repeatedly. which isn't a bash builtin, so it doesn't know about that. When you've installed new code it's rarely a bad idea to
$ hash -r # reset the command-lookup hashtable
or if you've got just one particular command in mind,
$ hash -dcommand# forget wherecommandcame from
You might need to add /usr/local/bin/ to your $PATH, perhaps in ~/.bashrc; you might want to put it before /usr/bin/ there.
And you could simply type the entire path of the binary, e.g.
/usr/local/bin/git --version
or
/usr/local/bin/git status
You might try to use strace to understand what is going on.
Did you read git INSTALL file? You probably want to go the autoconf way (e.g. make configure first, then configure with appropriate arguments....) and you surely need to give relevant arguments at configure time, in particular --exec-prefix= and/or --libexecdir= ....

Installing Git with non-root user account

I've already set up a Git repository on GitHub and committed a few changes from my Windows machine.
But tomorrow I'll have to work in this repository from a machine running Ubuntu with limited privilege (i.e. no sudo).
Is there a portable version of Git for Linux? Or some source that allows me to compile and install Git only for the current user?
You can download the git source and do ./configure --prefix=/home/user/myroot && make && make install to install git to your home directory provided you have the build tools. If you don't have the build-essential package installed (dpkg --list|grep build-essential), you will need to install those to your home directory as well.
I don't like link-only answers, but this link I followed step-by-step on a Fedora machine and it worked without modification. Very, very easy. The binaries end up in your ~/bin directory. You download a tarball, extract the sources, run make and run make install and that is it.
As the author states, the 2 prerequisites are gcc and ssh and if you meet these git should work for you as a non-root user.
To install git and dependencies from source the following maybe useful.
Replace with the location you are installing your non-root apps and consider checking for latest versions of source code.
wget https://curl.haxx.se/download/curl-7.47.1.tar.gz
tar -xf curl-7.47.1.tar.gz
mkdir <local_curl_dir>
cd curl-7.47.1
./configure --prefix=<local_curl_dir>
make
make install
wget http://downloads.sourceforge.net/expat/expat-2.1.0.tar.gz
tar -xf expat-2.1.0.tar.gz
mkdir <local_expat_dir>
cd expat-2.1.0
./configure --prefix=<local_expat_dir>
make
make install
wget https://github.com/git/git/archive/v2.6.4.tar.gz
tar -xf v2.6.4
mkdir <local_git_dir>
cd git-2.6.4
make configure
./configure --prefix=<local_git_dir>/git --with-curl=<local_curl_dir>/curl --with-expat=<local_expat_dir>/expat
make
make install
This is what I ended up doing, the main trick being the make flags:
wget -O git.tar.gz https://github.com/git/git/archive/v2.17.0.tar.gz
tar zxf git.tar.gz
mv git-2.17.0 git
cd git
make configure
./configure --prefix=`pwd` --with-curl --with-expat
# ./configure --prefix=`pwd`
# Make flags from https://public-inbox.org/git/CAP8UFD2gKTourXUdB_9_FZ3AEECTDc1Fx1NFKzeaTZDWHC3jxA#mail.gmail.com/
make NO_GETTEXT=Nope NO_TCLTK=Nope
make install NO_GETTEXT=Nope NO_TCLTK=Nope
Credits:
79E09796's answer above was a good tip, but didn't work for my case on Cloudways and did not require compiling curl and expat.
A random email record I found on the internet: https://public-inbox.org/git/CAP8UFD2gKTourXUdB_9_FZ3AEECTDc1Fx1NFKzeaTZDWHC3jxA#mail.gmail.com/
A related answer is https://askubuntu.com/a/350.
I could get it work with the third method proposed:
apt-get source git
cd git_vXXX
./configure --prefix=$HOME
make
make install
I don't know why, but when I had tried to install from the source download from github instead, I had a lot of problems with missing dependencies
Overkill workaround
Install Anaconda as a user and install git with conda.
Advantages
Anaconda can be installed as user, and a conda environment can be created which can help you to install other packages. This way you don't need to compile git from source, nor you need to install libcurl and perl, so you won't get the error
git: 'remote-https' is not a git command. See 'git --help'
after successfully compiling git.
Steps to install Anaconda, then git
read the Anaconda installation manual which points to the download page's shell script file.
Download the script file:
copy to your local machine and then copy with scp (e.g. winscp) to the Linux machine or
use a terminal on the Linux machine and issue wget https://repo.anaconda.com/archive/Anaconda3-2020.11-Linux-x86_64.sh.
add executable rights to yourself on the file by issuing chmod +x Anaconda3-2020.11-Linux-x86_64.sh
follow the installation instructions where you can also specify into which folder you want to install anaconda
after installation, chose one of the possibilities below to successfully invoke git later:
you either activate a conda environment, which is useful e.g. if you need to create different conda environments (it is common if you work with python). To activate an environment, you need to ask the installer (at the end of the installation) to add the conda initialization code into your ~/.bashrc file [see below]. Using this method, your path won't be polluted, and you will see if conda-related binaries are also in your current path. Or you can
add the installed bin's folder to your path, e.g. if you installed anaconda into /home/myusername/anaconda3, it will be in /home/myusername/anaconda3/bin. Your new executable file conda will be also there which will help you to install packages like git, python or pandoc, or
cd into the binary folder of anaconda, e.g. cd /home/myusername/anaconda3/bin, and execute the commands below.
don't forget to take into effect the new settings by, e.g., closing and opening the terminal again if you selected method 1. or 2. in point 5. If you selected 1, you will see something like (base) myusername#servername indicating you are using the base conda environment.
Now you can install git using conda by issuing conda install -c anaconda git.
Your .bashrc will contain likes like this if you told the Anaconda installer to initialize conda for you:
# content of your .bashrc in your home dir
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/home/myusername/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/home/myusername/anaconda3/etc/profile.d/conda.sh" ]; then
. "/home/myusername/anaconda3/etc/profile.d/conda.sh"
else
export PATH="/home/myusername/anaconda3/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda initialize <<<
for the latest version(which i mean git-2.25.0-rc1 or upper), you need to
wget https://github.com/git/git/releases/tag/v2.25.0-rc1 -O git.zip
unzip git.zip
cd git-2.25.0-rc1
export PATH=`pwd`:$PATH
and of course, you can add the last line into your .bashrc or .zshrc or something else for more convenience.

Resources