date int64 1,220B 1,719B | question_description stringlengths 28 29.9k | accepted_answer stringlengths 12 26.4k | question_title stringlengths 14 159 |
|---|---|---|---|
1,472,032,051,000 |
I can print the current git commit sha1 in bash using this command:
git rev-parse --short HEAD
But how can I print only the latest commit message/title of the HEAD?
|
I quite like
git show --oneline -s HEAD
If you only want to see the message, use
git show --pretty=format:%s -s HEAD
instead. To add the SHA-1:
git show --pretty=format:"%H %s" -s HEAD
(or %h for the abbreviated SHA-1).
See the git show documentation for details.
| How to print only git message/title using bash script? |
1,498,581,374,000 |
I tried this way:
pushOut=`git push`
But when I try:
echo $pushOut
I get an empty string
|
git push prints to stderr, apparently, so redirect stderr to stdout:
$ a=$(git push 2>&1)
$ echo "$a"
Everything up-to-date
| How to set a variable to the output `git push` command |
1,498,581,374,000 |
My Oh-my-zsh does the following:
When I run the git log --pretty --oneline command, it shows me a long list of commits, as expected.
As soon as I hit q, it suddenly disappears with the below output:
$ git log --pretty --oneline
FAIL: 141
Why is this happening, and how do I fix it?
|
The number after “FAIL” is the process's exit status. A process's exit status, as reported by the shell, is generally¹:
0 if the program exited normally and reported a success.
1 to 125 if the program exited normally and reported an error.
128+s if the program was killed by signal s, where s is a small integer.
141 ... | Oh-my-zsh deletes output of successful command with "FAIL: 141" |
1,498,581,374,000 |
I'm working on a CentOS 7.9 GNU/Linux system. I've built and installed a newer version of git (2.34.1 instead of 1.8.3.1 that's bundled with the distribution) under /opt/git/2.34.1, with a symlink to that directory at /opt/git/current; and I've added that symlinked directory to (the beginning of) my $PATH variable.
Un... |
Git uses libcurl library to push/fetch repositories via http:// and https://. This error occurs if you compile git without the library present.
Install it (yum/dnf install libcurl-devel) and then reconfigure and recompile git. It should work.
Link: https://github.com/git/git/blob/b896f729e240d250cf56899e6a0073f6aa469f... | git clone from https URL fails, says it's 'remote-https' is not a git command and that templates werent' found |
1,498,581,374,000 |
I want to install git on my debian 9 (stretch ) machine ,
when I type :
sudo apt install git-all
I get this message :
Reading package lists... Done
Building dependency tree Reading state information... Done Some `packages could not be installed. This may mean that you have requested an impossible situation... |
The problem is this:
http://ppa.launchpad.net/git-core/ppa/ubuntu focal
You can’t use a Ubuntu focal PPA on Debian 9. Remove that from your configuration and you’ll be able to install git.
You probably don’t need git-all either,
sudo apt install git
should be sufficient.
| Can't install git on debian9 (stretch) |
1,498,581,374,000 |
I have this in my .zshrc:
# command completion
autoload -Uz compinit
compinit
usually letting me tab through commands, args, and files.
But with git --git-dir=<the path> --work-tree="$HOME" (usually aliased) it only works for sub-commands (like add and push) and args, not files. I'd like it to work with files too.
I ... |
If --git-dir is present on the command line, the completion code recognizes it and takes it into account when looking for things to complete, if your zsh is recent enough (≥5.3). It does so by passing the argument to --git-dir as the environment variable GIT_DIR. For example, to complete remote names after git fetch, ... | Zsh file autocompletion with bare git repo |
1,498,581,374,000 |
The Arch Linux git package installs git-gui under /usr/lib/git-core/.
This means git-gui cannot be launched directly from the terminal without specifying the full path:
$ git-gui
bash: git-gui: command not found
$ which git-gui
which: no git-gui in (/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/lib/jvm/defaul... |
This is expected behaviour. All git sub-commands are installed to there — you will also find git-commit there, though probably as a link to the main binary for efficiency these days — and the main git command knows where to find them.
Any executable git-X there becomes available as git X automatically, and that's the ... | How to properly solve "git-gui: command not found" on Arch Linux? |
1,498,581,374,000 |
I'm trying to make an automated backup of my /home directory. In theory this is simple by running this in a cronjob:
cd /home
git add .
git commit -m "nightly backup"
git push
where push will push the changes to a remote backup server.
The problem I have is if there is a git repo in the /home directory e.g. /home/tom... |
I know my comment is not a quite straight answer, but... I would recommend re-organizing your backup methodology in following ways (either / or):
Having single "major" repo with all subprojects inside it: one repo for /home I mean. That may look crazy at a first glance, but it depends on complexity of your sub-projec... | Git Backup /home with other repos inside it |
1,498,581,374,000 |
I am mirroring a Subversion repository tag with svn2git and I want to be sure that when I checkout particular revisions, those I obtain from the git mirror match those from Subversion. My main problem is that subversion tags can be updated, and I need to ensure that checking out the matching tag in the git mirror, mat... |
diff -qrN is about as fast as it gets to compare two directory trees. The -q option makes it quit early when files differ. Since you expect the files to be identical most of the time, it doesn't matter all that much: the comparison tool has to read and compare the whole files anyway.
The only improvement you can make ... | What optimized tools are available for comparing directory contents? |
1,498,581,374,000 |
I use git on a regular basis for collaboration with other people. When we work together on a shared repository, I'd like to be able to view the changes performed by others which happened between my last commit and the current master branch (or the current HEAD).
Until now I'm using the following workflow:
git fetch ... |
This is not a very 'git like' way to approach the problem. Normally you would just keep a branch which pointed to your last commit.
However to answer the question, try the following helper function. This is not going to be very efficient, I probably need to user some lower level commands.
my_last_commit(){
loc... | Display git-diff between master and my last commit |
1,498,581,374,000 |
I have searched the whole universe this error but i could not find any helpful tips.
I have created a key using keybase and added my public key to github gpg
my gpg --list-secret-keys --keyid-format LONG
is this
--------------------------------
sec rsa4096/7E8*******60B47B 2021-03-06 [SC] [expires: 2037-03-02]
... |
i resolved my issue by adding gpg-agent plugin to my zshrc config file.
| gpg failed to sign the data, failed to write commit object |
1,498,581,374,000 |
What is the proper way to checkout a bunch of .*rc files into a home directory?
I've seen lots of github repos online and people usually name them dotfiles, and I guess they get checked out into their home directory; but what I don't understand is...
How does one keep their other home files (specific to that machine) ... |
An option is to use symbolic links. For example, say I have my git checkout out in ~/.dotfiles. I might have:
.vimrc -> ~/.dotfiles/vimrc
.bashrc -> ~/.dotfiles/bashrc
.bash_login -> ~/.dotfiles/bash_profile
...
I would not, personally, check my home directory itself into the repo.
| Proper way to checkout home directory .rc files from a git repo? |
1,498,581,374,000 |
I am trying to make a command for having a nice-looking git log. Say I have the following:
git log --color --pretty=format:"%C(cyan)<%an>" --abbrev-commit
What I would like to do is to make a variable that takes %an and decides what colour it will be based on the output string.
So far, I have
USER=$(if [ ! %an = "m... |
You are trying to put a shell script into Git's formatting parameter. Of course, it won't work.1
There are some Git parameters that actually accept shell script, like ones of git filter-branch; but they will be explicitly specified as such in the corresponding manual page.
What you are trying to accomplish could act... | Echoing from a variable in a specific part of a string |
1,498,581,374,000 |
This is completely theoretical, but I'm new to Git and Linux so I want to know.
If I accidentally manage to do git init inside e.g Desktop or Home directory, how to prevent any possible disaster from happening?
git init creates hidden .git directory where it's config-files are so is it just so simple to remove this hi... |
If you run git init in a directory which isn’t already a git repository, removing .git will reverse all the effects of git init without any other side-effects.
| Git init in wrong directory? How to recover? (theoretical situation) |
1,498,581,374,000 |
Using source-highlight in conjunction with less works really well, but I'm struggling to see how I can use it with git show because there's no file extension to clue source-highlight about the language used in the git output...
less somefile.rb # result is syntax colourised
git show master:somefile.rb | less # no colo... |
I ended up modifying gnu source-highlight's src-hilite-lesspipe.sh so it could work with piped files: https://gist.github.com/jaygooby/9494858d3d481a64819d227a9318f6c7
This means that as well invoking in a regular fashion:
less code.py
You can also get source highlighting for extensionless files that don't have any o... | How can I use "source-highlight" with "git show"? |
1,498,581,374,000 |
I need to insert user credentials into an HTTP string so I can properly populate my git credentials file at ~/.git-credentials.
These are the three environment variables I have to start with:
user="someUser"
pass="somePass"
uri="http://sometld.org/path/repo.git"
I've been fiddling with awk, but it will only work with... |
$ sed -e "s^//^//$user:$pass@^" <<<$uri
http://someUser:[email protected]/path/repo.git
This replaces // with //$user:$pass@ in the string $uri and will work anywhere.
In Bash specifically:
$ echo ${uri/\/\////$user:$pass@}
http://someUser:[email protected]/path/repo.git
will perform the same replacement - this is j... | Insert credentials into HTTP string? |
1,498,581,374,000 |
possible duplicate : watch command not showing colors for 'git status'
running the following command:
watch -n1 git --no-pager log --oneline --graph -20
reproduces what i expect only it strips colors. In the possible duplicate it says that git detects that stdout is not terminal and hence strips the colors but the sol... |
Rather than always forcing git to color, you can enable color for just one command with a flag:
git log --color
So your command would be:
watch --color -n1 git --no-pager log --color --oneline --graph -20
I'm not sure why the linked answer didn't work, but I hope this works better.
| why does watch remove the colors from git log |
1,498,581,374,000 |
I used cp -uav to update a copy of a git repo, including uncommitted files.
Why did it say it's removing files? It looks like this:
$ cp -uav repos copy
removed 'copy/repos/h/.git/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391'
removed 'copy/repos/h/.git/objects/3b/b3f834dd037db9298b10d71e0cd7383000fa1c'
removed '... |
I can reproduce the above messages as follows:
mkdir test; cd test
mkdir repos; cd repos
mkdir g; cd g
git init
touch a
git add a
git commit -m test
cd ..
git clone g h
cd ..
mkdir copy
cp -ua repos copy
cp -uav repos copy
The running the cp -ua command under strace will show that it is indeed removing (unlink) th... | Why did `cp -uav` of a git repo show "removed" for some files? |
1,498,581,374,000 |
I'm learning about SHA1 (specifically wrt Git), and I wanted to sanity-check my understanding by calculating a string's SHA1 with different methods - I expected identical SHA1 hashes, but instead I got distinct results from three of four methods:
>git hash-object --stdin <<< "Apple Pie"
23991897e13e47ed0adb91a0082c31c... |
The differences don't come from SHA1, but the input. The here-string syntax appends a newline, as we can see with od:
$ od -c <<< foo
0000000 f o o \n
So in your git command the input is the ten characters Apple Pie\n.
In addition, the double quotes you used in the here-strings don't support backslash escapes... | Different methods to get SHA1 give different results |
1,498,581,374,000 |
I have a bash script that I've written during the course of the last week. Today, I've decided to finally give git a try before making any further changes, created a git repository, etc.
The script has two versions: script.sh and script1.sh. My question is whether there is a way to tell git that the latter is an updat... |
Yes, you overwrite script.sh with script1.sh, after an initial commit. Starting from scratch:
git init
git add script.sh
git commit -m "First version of script.sh"
mv script1.sh script.sh
git add script.sh
git commit -m "Second version of script.sh"
You'll then be able to see both versions of script.sh in git log, ch... | git: how to add one file as a version of another? |
1,498,581,374,000 |
I just recently installed gitg and whenever I tried to make a commit, I encountered an error of missing author details. However, I am unable to change author details as no editing window pops up after I clicked on the the author details tab...
|
To get rid of the error you need to set your user name and email address.
There are two main contexts where you will likely want to set this
Specific to your user account i.e. ~/.gitconfig
This setting will apply to any git project belonging to your user account
On a project specific basis i.e. in <your_git_project>/... | how to edit author details for gitg? |
1,498,581,374,000 |
I need to let untrusted users, strangers, upload their id_rsa.pub to my server and onto a given user's authorized_keys (user git in my case). What is the safest way of achieving that, without having to do anything manually?
I am particularily thinking about a web interface, but if there are strong advantages of anothe... |
Use another processes as a middle-man. Your web service (or whatever) writes new requests to a spool somewhere. The middle-man watches the spool, removes and sanity checks new entries, and append what's valid to git's authorized_keys file. The same middle-man can give feedback that the web service can read. But a ... | Safe way of letting users upload their public keys |
1,498,581,374,000 |
I want to run the following commands:
git diff
git commit
git commit will open the default editor to edit the commit message. But if the difference if not too long it will close immediately.
How can I prevent closing git diff before pressing Enter or other keys?
|
git uses less as a pager. If you want to use the pager on a specific, just pipe the output directly to less (git won't try to invoke less itself if it is outputting to a pipe, so no need to worry about have two less processes). Just do:
git diff | less
You could also add similar options to less that git does to get t... | git diff - listen for key press |
1,498,581,374,000 |
How can I get total size of Git LFS files?
I can get a listing of LFS files with git lfs ls-files --size:
b1d5dd29dd - file1.zip (1.42 GB)
27d3073f43 - file2.zip (120 MB)
cacd6dbfe3 - folder/file3.zip (110.2 MB)
295442cd34 - "folder/(120 MB).zip" (110.2 MB)
680bb2ab19 * test.txt (5 B)
Note: both - and * are used.
I c... |
I can't find any option specifically to print sizes in bytes rather than human readable sizes however it looks like the --debug option does this. The output of --debug is quite different though and according to the man page "the exact format may change at any time" so keep that in mind.
However with the sizes in byt... | Get total Git LFS size |
1,498,581,374,000 |
As background, I'm using git on an hp-ux 11.11 (11v1) system. I'm doing an extensive .gitignore file to exclude many many files. My .gitignore is basically "Ignore everything, except these directories, but also ignore these patterns under those directories." Precisely how and why is not exactly relevant to the questio... |
find . -type f -print -o -name . -o -prune
Is a more convoluted way to find regular files in the current directory and not in subdirectories than the more canonical:
find . ! -name . -prune -type f
Which with the GNU implementation of find (or those which have copied GNU find's -mindepth/-maxdepth) can also be wri... | How does find . -type f -print -o -name . -o -prune actually work? |
1,498,581,374,000 |
Basically i have a automated building script where i do a checkout of a local branch, and want to step to pull remote updates with git pull && git submodule update && make clean only if necessary, because otherwise i'd be wasting a lot of time when it was time to build.
I noticed that if had a local change going on an... |
You are going to need to get the information from the remote repo at some stage. At the moment you are using git pull to download the information and merge it. You should split this into 2 steps, first download the information of the state of the remote repo. As a second step see if you are up-to-date, if not then mer... | Is there a better way than string output hacks to check git checkout needs a pull to update? |
1,498,581,374,000 |
I'm trying to extract the name of the folder created by git. The output says:
...
Cloning into 'repository-name'...
...
I want to pipe this output into grep to extract the one line that says Cloning into 'repository-name'. However, when I run git clone https://github.com/username/repository-name.git | grep "Cloning i... |
From git-clone man page:
--progress
Progress status is reported on the standard error stream by default when it is attached to a terminal, unless --quiet is specified. This flag forces progress status even if the standard error stream is not directed to a terminal.
So we have to do Redirecting of Standard Descriptor... | How do I grep output from git? |
1,498,581,374,000 |
I occasionally encounter such an error:
$ which bash
/usr/local/bin/bash
bash: prompt_git: command not found
The report is obscure, since I did not manipulate git. When it's rebooted, the error disappear. However, it will abruptly emerge after some uncertain operations were executed.
|
The problem you are having is caused by a bad setting in your .bash_profile/.bashrc file.
One of the shell variables PS1 or PROMPT_COMMAND contains a call to prompt_git which is not (at that point) in your PATH. PS1 defines the prompt you see in the terminal and PROMPT_COMMAND is run every time the prompt is displayed... | error `bash: prompt_git` report when no git operations performed |
1,498,581,374,000 |
On Cygwin, running git clone git@..., git pull or git push, where the remote is an SSH repository address, fails. Below is output of running git clone:
Cloning into 'iko-app-rocket'...
fatal: cannot run C:\Users\sakynimoD\scoop\apps\openssh\current\bin\ssh.exe: No such file or directory
fatal: unable to fork
As you c... |
Since you discovered that explicitly setting GIT_SSH=ssh works, the next thing to investigate is if it was already set, possibly by scoop. You can check by running echo "$GIT_SSH" or alternatively by running env to display the entire environment.
If it is set, that could either be coming from Windows' environment vari... | Git functions requiring SSH broken on Cygwin |
1,498,581,374,000 |
How can I modified this script to conditionally execute ${deleteOldBranchRemote} when there is no error executing ${getRename}?
Now_hourly=$(date +%d%b%H%M)
#echo "$Now_hourly"
newrcName="rc$Now_hourly"
#rename rc to the new name
getRename="git branch -m $newrcName"
#Delete the old-name remote branch
deleteOldBranchR... |
You can write it like this:
if git branch -m $newrcName; then
git push origin --delete rc
fi
So the second command is only executed when the first command finishes with an exit code of 0 which indicates success.
You can get more info about the if keyword by running help if. Example output from my system (Bash 4.3... | Checking for errors in bash script |
1,498,581,374,000 |
Suppose we have a directory with a git repository & files:
.git
/test/inside-1.txt
/test/outside-1.txt
outside.txt
inside.txt
"inside" files are within git repository, "outside" are not. I'd like to know, how to get the files, that are outside repository and inside.
I know, how to get "inside": I need to run git ls-f... |
Maybe you can try with git ls-files --others --exclude-standard. This should list files which are not defined in .gitignore.
| How to find out which files are outside git repository |
1,498,581,374,000 |
I basically want to find all git repos that have neither a .gitattributes nor a .gitignore file at the root.
I used find . -type d '!' -exec test -e "{}/.gitignore" ';' -print to find it but it lists out all the directories instead of only the top level git directories.
My directory tree looks like this:
GitHub
├─ _Cl... |
To list the root directories of git repositories, I use the following:
find . -name .git -print0 | xargs -0 dirname
A variant finds all folders containing .gitignore:
find . -name .gitignore -print0 | xargs -0 dirname
Determining git repositories whose root doesn't contain .gitignore is then simply a set operation o... | Find all git repos that do not contain any one of .gitignore and .gitattributes |
1,498,581,374,000 |
dir1 has 1 file and dir2 has 2 files as below:
/tmp$ ls dir1
file1
/tmp$ cat dir1/file1
line1
line2
line3
/tmp$ ls dir2
file1 file2
/tmp$ cat dir2/file1
line1
/tmp$ cat dir2/file2
line1
/tmp$ diff -ur dir1 dir2 | diffstat
file1 | 2 --
file2 |only
2 files changed, 2 deletions(-)
I am looking for a command to ... |
You need to use the -N (treat missing files as empty) option to diff. For example:
$ diff -N -u -r dir1/ dir2/ | diffstat
file1 | 2 --
file2 | 1 +
2 files changed, 1 insertion(+), 2 deletions(-)
| git --diff like command for Linux local dirs |
1,498,581,374,000 |
So I have a python script that pulls down git/svn/p4 repositories and does some writing to a database.
I'm simply trying to automate the running of this script and based from what I see in syslog it is being run, even the file I tried piping the output to is being created however the file is empty. Here is the cron jo... |
So it turns out the problem was with environment variables that the Python script needed, and it was so early on in the script that it broke the script before it even output anything.
Cron does not have a regular environment.
Furthermore ssh passwords were required for pulling git repos which i was able to solve by us... | Cron job not behaving as expected |
1,498,581,374,000 |
I've started working with a git repository that includes a large amount of content that should be assumed readonly. So, every time I throw a new branch:
git checkout -b newBranch
it should be followed by the command
git update-index --assume-unchanged LARGE_READONLY_DIRECTORY
I figured this would be a perfect oppor... |
You need a space between [[ and $2.
For bash [[ is not syntax, it is a builtin command (or keyword to be precise). Bash will execute [[ with all its parameters, including the closing ]]. When you have no space between [[ and $2 bash will not see the keyword [[, instead it will see this thing: [[-b (after expanding $2 ... | How to extend a command in bash so that it expands based on options? |
1,498,581,374,000 |
I have found a patch applicable to my system to fix a problem but I have no idea how to get this patch and then apply it. Can anybody help me please?
Patch: https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=c11e5f35ab490bd30591563816fbc83526521777
|
First, download the patch. There is a handy patch button on the link you indicated. Say for instance, you saved it to /tmp/foo.patch
cd into the source directory and run the following
cd drivers/gpu/drm/i915/intel_pm.c
patch -p1 < /tmp/foo.patch
You could alternatively use git-am to create and apply the patch. Assu... | How do I apply this revert commit patch from git? |
1,498,581,374,000 |
I have a project with a lot of submodules and I want to delete all remote branches named foo in the submodules, if it exists.
I am trying to following:
git submodule foreach git push origin :foo
This works as intended if the branch exists in all submodules, but if any of the submodules is missing the branch, the fore... |
From the git submodule man page:
A non-zero return from the command in any submodule causes the processing to terminate. This can be overridden by adding || : to the end of the command.
This means the following should do the job:
git submodule foreach 'git push origin :foo || :'
The || is an OR and executes the nex... | Remove branch from all submodules |
1,498,581,374,000 |
Current code to generate change logs:
svn2cl --linelen 78 --reparagraph --include-rev --group-by-day
The closest I could get with vanilla options is
git shortlog --format='* [%h] %s' -w78,8,10
How do I emulate the svn2cl output as closely as possible?
Example output:
2013-02-19 username
* [r30695] path1: c... |
Another solution gave the right direction. The result so far:
#!/usr/bin/env bash
while read -r -u 9 date name
do
echo "$date $name"
echo
GIT_PAGER=cat git log --no-merges --committer="$name" --since="$date 00:00:00 +0000" --until="$(date --date="$date + 1 day" +%Y-%m-%d) 00:00:00 +0000" --format=' ... | Git changelog grouped by day and user |
1,498,581,374,000 |
I'm cloning a popular open source project into GitHub, and I only realized this after it was too late. I'm also trying to convert this project over to use Maven instead of Ant/Ivy for a build tool. I was able to convert the repository from SVN to Git via the aptly-named svn2git, then started making changes toward the ... |
This sounds really simple to fix assuming you made all your commits to master. Here's a high-level description of the steps (tailor commands to your specific repo).
Make a new branch at your current HEAD (e.g. with git branch <newbranch>)
Switch to the current master (git checkout master).
Track down your origina... | Revert commits and commit them to a branch? |
1,498,581,374,000 |
I am looking for a formatter to use with my git commits. par pretty much does what I want, with the (important) limitation that I can't get it to properly format bullet lists, which are pretty common in commit messages.
For instance:
% export PARINIT="rTbgqR B=.,?'_A_a_@ Q=_s>|"
% par << EOF ... |
Pandoc will do that:
$ pandoc -t plain <<EOF
> [JR-1234] This is a fix for the thing.
>
> I am a developer that doesn't like linebreaks. I am a developer that doesn't like linebreaks. I am a developer that doesn't like linebreaks.
>
> - I am a developer that doesn't like linebreaks. I also like bullet lists. I li... | text formatter that supports bullets |
1,498,581,374,000 |
Appologies for the vague title.
I frequently execute git branch throughout the day, and it seems at some point recently (perhaps in the past month?) the behavior has changed. I recall previously git branch would print the list of branches and immediately return to a prompt -- however it now appears to be printing the... |
git branch defaults to using a pager since version 2.16.
You can configure that by changing pager.branch, e.g.
git config --global pager.branch false
or on an ad-hoc basis by adding the -P (--no-pager) option.
less does have an option to exit if the data it is asked to display fits on a single screen, -F. When the LE... | Is `git branch` using `less` a recent change? Or is `less` behaving differently recently? |
1,639,406,504,000 |
I'm using git aliases from zsh plugins: https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/git
So it has git aliases like:
gst # git status
ga # git add
gc "commit" # git commit -v "commit"
...
...and I'm also using git bare repo to backup all my dotfiles: https://github.com/Anthonyive/dotfiles/blob/0706bc81daa3a... |
The associative array aliases contains all alias definitions.
for name in "${(@k)aliases}"; do
if [[ $name == g* && $aliases[$name] == 'git '* ]]; then
alias d${name#g}="dotfiles ${aliases[$name]#git }"
fi
done
Alternatively, you could change the d alias to a function that expects a following git command, but... | Create new set of aliases based on current set of aliases (eg. gst -> dst)? |
1,639,406,504,000 |
I need to test a debugging tool on a variety of outdated distributions. I managed to install build-essential package on Debian Squeeze. The problem though is now that it's impossible to download sources from GitHub/GitLab with either git or curl/wget. The reason is simple - deprecation of the older SSL protocols, whil... |
In wheezy, git depends on libcurl3-gnutls 7.26.0 which in turn depends on libgnutls26 2.12.17. Curl depends on libssl1.0.0 1.0.1 (that's OpenSSL). These series are very out of date and I don't think current versions have a compatible ABI. So just compiling SSL libraries and putting them in /usr/local won't cut it.
If ... | How to use curl/git in Debian Squeeze with modern HTTPS? |
1,639,406,504,000 |
I use git to track my dotfiles across multiple machines. I wrote a pretty simple script in the repo, which backs up any outdated existing dotfiles and then creates symbolic links to each of the up-to-date dotfiles. Here is the script:
#!/bin/bash
############################
# makesymlinks.sh
# This script creates sym... |
Here's the output in your question annotated:
drakeprovost@shatterdome:~/RoverCoreOS$ git clone https://github.com/DrakeProvost/dotfiles.git
Cloning into 'dotfiles'...
remote: Enumerating objects: 42, done.
remote: Counting objects: 100% (42/42), done.
remote: Compressing objects: 100% (30/30), done.
remote: Total 42 ... | My dotfiles bash script somehow deleted its own directory? |
1,639,406,504,000 |
I'm trying to configure my own git repository server with Git SmartHTTP and Apache2. So followed these instuctions from the official git manual. But during the configuration it becomes not clear to me, what the GIT_PROJECT_ROOT variable exactly configures: Does it set the path to exactly one repository on a webserver ... |
There is a description in the git-http-backend manual.
Variable GIT_PROJECT_ROOT is set to a parent path of all repositories and similar to the Apache DocumentRoot directive, it is used to translate an URL-path to the filesystem:
URL TRANSLATION
To determine the location of the repository on disk, git http-backend c... | Git repository server GIT_PROJECT_ROOT |
1,639,406,504,000 |
I have the following lines in my ~/.aliases:
function __function_exists() {
declare -f -F $1 > /dev/null
return $?
}
# git aliases (need to have git bash completion installed)
for al in `__git_aliases`; do
alias g$al="git $al"
complete_func=_git_$(__git_aliased_command $al)
__function_exists $com... |
Actually, calling _git from your .zshrc does work, in that it defines _git and its companion functions including __git_aliases, and it tries to do some completion but fails (without even an error message in this particular case). This works with most completion functions. You need to do this after compinit so that _gi... | Define git aliases based on gitconfig in zsh |
1,639,406,504,000 |
I am aware that it is possible to forward SSH from server A to server B by creating a tunnel.
What I am asking for is rather the red alternative on the schema above.
Can this scenario be implemented:
SSH to server A
Server A tells client to go to server B instead
Server B communicates directly with client over SSH
... |
Unfortunately there is no flag to turn on in SSH to do this. You'd have to code something custom for GIT. (i.e. if serverA has lower ping time than server B use A or vice vera)
| Is it possible to redirect ssh traffic (not forward), How? |
1,639,406,504,000 |
I've just run tar x by mistake instead of tar c, and overwrote my git repo with a few days older version. This will have left alone any files I had newly created though, including objects in .git. How can I recover as much as possible?
|
Make a copy of the whole mess first, just in case.
git fsck will show dangling objects and commits. Find the newest dangling commit. I fed all the commit hashes to gitk, and it just shows the most "recent" one at the top. As well as only having a few commits to deal with, I only had a single branch to recover - thi... | Recover a git repo which was overwritten with an older version |
1,639,406,504,000 |
Studying the Github backup-utils I found the command bm_start inside their scripts. This is an example that uses the bm_start and bm_end, with some other code between them.
According to the project page, the pre-requisite to use the scripts is:
Linux or other modern Unix operating system with bash, git, OpenSSH,
an... |
They're shell functions defined in share/github-backup-utils/bm.sh, pulled in via share/github-backup-utils/ghe-backup-config.
| What does "bm_start" do in a bash script? |
1,639,406,504,000 |
I would like to do something like:
git clone https://github.com/meteor{A,B,C,D}test
but bash does not convert the {} into an each. What am I doing wrong?
|
The syntax you are using {A,B,C,D} is valid, but it results in argument splitting. Meaning your command will be run as:
git clone https://github.com/meteorAtest https://github.com/meteorBtest https://github.com/meteorCtest https://github.com/meteorDtest
What you want is to run 4 different commands. One simple way to ... | Clone repos with a similar name |
1,639,406,504,000 |
I want to be able to push a repository to Github at midnight, every night. I know that Github isn't a back-up service, and, in no way am I expecting it to be this - I just want the best up-to-date version on Github and this works for me, and, my team. What I was thinking is this:
Creating a Bash script that pushes th... |
As the links described as harish.venkat
Create a script /path_to_script, which would add new file, commit and push.
#!/bin/sh
cd /location/of/clone
git add *
if [[ $? != 0 ]] then
mail -s "add failed" [email protected]
exit 1
fi
git commit -a -m "commit message, to avoid being prompted interactively"
if [[ $?... | Crontab with Github |
1,639,406,504,000 |
Whenever I tab-complete a file path after a git command in bash, e.g. git add, I have to press <TAB> multiple times to complete to the actual filename, depending on how many subfolders there are up to the file.
Example: I want to add the file my/example/file, then I enter:
git add <TAB>
git add my/<TAB>
git add my/exa... |
One way to accomplish this would be to copy the git completion script,
/usr/share/bash-completion/completions/git, to
~/.local/share/bash-completion/completions/ and modify it to complete with
full index paths:
mkdir -p ~/.local/share/bash-completion/completions
cd ~/.local/share/bash-completion/completions
cp /usr/s... | bash tab-completion: complete full path on single tab in git commands? |
1,639,406,504,000 |
My scenario is as follows: After updating files on my Git repository, I have a Git hook that calls an API from my web server. This API performs a Git pull and then I have a Git hook post-merge that restart the web server (Gunicorn). The restart of the web server should occurs a few seconds after the pull is completed ... |
Finally I ended up with this one line in the file .git/hooks/post-merge
#!/bin/sh
( sleep 10 ; /usr/bin/sudo systemctl restart tempcollect ) &
| Add a delay in git post-merge |
1,639,406,504,000 |
When I edit a file, and then want to undo my changes, I use
git checkout -- file.txt
the problem is that git does not keep the file permissions of the existing file. file.txt has permissions 644, but after git checkout it has 600 (which I think comes from my umask)
I know git does not store file permissions, and I am... |
When Git checks out files, it by default uses the umask of the file on the system, setting the executable bit if it's a directory or it's marked as an executable file. That's because Git removes and re-creates the file, so it doesn't preserve the permissions of the existing file.
This is actually by design, because t... | git checkout -- file changes permissions for existing file |
1,639,406,504,000 |
I am using a Debian 9 server.
Usually I access via ssh to a normal user (say user1) and su into root, because I disabled ssh into root.
Lately I was setting up a git-server where I created a user git with the group git and restricted him to git-shell.
Playing around a little while I added user1 to the group git like t... |
Solved only with rescue mode:
boot into "rescue mode" - probably available at most VPS
mount appropiate drive
nano /path/to/mounted/drive/etc/passwd
change root entry to root:x:0:0:root:/root:/bin/bash
save, exit and reboot without rescue mode
Different approaches like
user1@hostname: ~$ su -s /bin/sh
or
user1@ho... | Cannot su into root default shell - Debian |
1,639,406,504,000 |
I'm expecting Git to create a merge commit when I merge a signed or annotated tag but instead it fast-forwards the branch pointer. I'm using Git version 2.17.0 on openSUSE Tumbleweed that comes with it.
According to the manpage of git-merge(1) it should create a merge commit in case of merging a signed/annotated tag:
... |
Note the part of the manpage that you'd quoted that I've bolded below:
This is the default behaviour when merging an annotated (and possibly
signed) tag that is not stored in its natural place in refs/tags/
hierarchy.
With the command sequence that you gave, the tag would be in its natural place, so the conditio... | Git not creating merge commit when merging signed/annotated tag |
1,639,406,504,000 |
Here is my error:
fatal: cannot update the ref 'HEAD': unable to append to '.git/logs/HEAD': Invalid argument
Etckeeper worked until today. The only recent change to the system has been the upstream git repository. The .git directory is now on an sshfs mount. I now understand that's related to the problem. The proble... |
When you use sshfs to mount the directory, also specify -o writeback_cache=no:
sshfs -o writeback_cache=no [user@]host:/dir/ /localdir
See https://github.com/libfuse/sshfs/issues/82 for more.
| Git repository on SSHFS: unable to append to '.git/logs/HEAD': Invalid argument |
1,639,406,504,000 |
For example: I have a kernel 3.16 from my embedded support, but I want to have some network wireless drivers from 3.19. What is the best way to merge only this drivers (not full kernel)?
I tried merge, but it results in many conflicts.
Copying files from 3.19 to 3.16 is a lot of work and results in many missing funct... |
Finally the best option for me was :
Copy drivers files from 3.19 into 3.16 directly.
Before commit, thanks to git difftool check every change with previous code.
If change uses newer kernel function then get back to older function or add newer function files from 3.19 kernel
Compile - if errors then get back to 2.... | Merging part of kernel - best way? |
1,639,406,504,000 |
I have the problem, that we login to the systems as our own users johndoe and then have to do a sudo su - root to be able to do administrative tasks. We have the system config files in a git repository (which makes everything better). But now I lose the settings in the user's (johndoe) /home/johndoe/.gitconfig file.
I... |
To answer my Question: No
This is the solution i ended up with:
I added a file /etc/profile.d/gitsetup.sh with the following content:
[ -z "$PS1" ] && return
[ -z "$BASH_VERSION" -o -z "$PS1" ] && return
CFGFILE="/home/$(who am i|awk '{ print $1 }')/.gitconfig"
[ $USER == "root" -a -f "$CFGFILE" -a -n "$CFGFILE" ] && ... | Is it possible to set the users .gitconfig (for git config --global) dynamically? |
1,639,406,504,000 |
I am just playing around with bup for my backups and tested it like this:
BUP_DIR=/mnt/TestTarget/bup bup init
Which gave me the message: Initialized empty Git repository in /mnt/TestTarget/bup/
However in /mnt/TestTarget there seems to be not .git directory.
bup index -uv /home/user/TestSource
bup save -n buptest1 /... |
As @GHugo suggested, using the commands described in my question, produced a backup in ~/.bup. There it is possible to browse it via gitk if you remember to click on tree (and not on patch).
Now If one wants a backup in /mnt/TestTarget/bup the following steps worked for me:
BUP_DIR=/mnt/TestTarget/bup bup init
bup -d... | Browsing bup backup with gitk or gitg |
1,639,406,504,000 |
This repository had a large subdirectory of large files that months ago I removed from the commit and that I now want to remove from the repo forever. The massive subdirectory is no longer in the download but the objects directory is enormous.
The checkouts/clones take a long time and I believe this is because of the... |
This answer using index-filter worked for me where the others did not :
https://stackoverflow.com/a/32886427/4386557
| git remove from repo history a large subdirectory that was removed several commits ago |
1,503,604,290,000 |
I have a NAS (WD MyCloud) which has by default NFS/SMB access enabled. I also have a raspberry pi, that I would like to use as a git server that is addressable over internet using a SSH connection. The data would be stored on the NAS.
To sum up:
Internet -> router -> raspberry -> NAS
I've managed to mount the NAS shar... |
I found this question on my StackExchange profile. Since then, I found the answer I was looking for:
Instead of doing NFS mounts, I am now using SSHFS to access the files, which gives me encryption and authentication on the NAS.
The public key of the raspberry is saved on the NAS and configured so that I can do a ssh ... | mount a NAS network share, but let the NAS sleep |
1,503,604,290,000 |
i like to write a oneliner which gets me all remote url from my cloned repositories underneath my git_repo folder (personal git root folder) and to pipe into a file
my idea was something like
cat */.git/config | grep remote.origin.url= >> git_repos.txt
but of course this does not work.
|
This will list all your remote URLs for remotes named “origin” in any git repositories beneath the current directory:
find . -path '*/.git/config' -execdir git remote get-url origin \;
It finds files named config inside a .git directory, and from every containing directory, runs git remote get-url origin which shows ... | get all git remote.origin.url from exisiting clones in sub directory |
1,503,604,290,000 |
I'm trying to write a bash line that will look at all the subdirectories in my current folder and tell me if any do NOT contain a ".git". Pseudo:
for subdir in currentdir
if .git does not exist
print subdir
Here's the one-liner I'm trying, which isn't working and seems to print all the subdirectories:
find . -m... |
First, the -execdir command looks wonky (2x $SHELL -c?):
$SHELL -c '[ ! -d ".git" ] && echo "not git repo:" {}' $SHELL -c '{}' ';'
Also, -execdir runs the command in the directory containing the matched entity, (so the parent directory of the directory that it is checking right now), which is . for all subdirectorie... | Print all subdirectories in the current directory that do not contain a .git |
1,503,604,290,000 |
So I'm using etckeeper on my machine running Debian 9.1 with KDE and would like to view diffs (or if that isn't yet implemented: past versions) of specific files. How can I do that?
|
By default, with etckeeper, /etc is a git repository, so you can use git tools to view its contents (and the changes). For example, you can use gitk (after installing it) to browse the repository’s history, and if you want to focus on a specific file, you can specify it on the command line:
cd /etc
gitk apt/sources.li... | How can I view diffs or at least older versions of specific files with etckeeper? |
1,503,604,290,000 |
I was following through the git documentation and installed Git using source code package. Now, after installing Git, I want to update it (Though it might be unnecessary at this time, I simply want to try and make sure it works). I ran the command git clone git://git.kernel.org/pub/scm/git/git.git and it returned erro... |
What does hash say? Did you have a /usr/bin/git previously and then removed it? That would lead to bash: /usr/bin/git: No such file or directory while hash still believes git to be there.
The solution in this case would be to either use a new shell. Or for each shell with the old hash, reset it using hash -r.
| couldn't update git via git clone comand |
1,503,604,290,000 |
I'm trying to get an output of one function and pass it to other.
set -x
OUTPUT=$(git diff --name-only --diff-filter=AM develop... | sed 's/.*/"&"/')
./bin/phpcs $OUTPUT
My main problem is that the first function returns a list of files and files may contain spaces. So I'm wrapping them in double-quotes, but when I p... |
Your issue is that you are adding double quotes to the text outputted by git diff. This mangles the pathnames and makes it even harder to correctly parse the file list, especially if any pathname happens to contain quotes.
The single quotes that you see in the tracing output is just added by bash to make it easier to... | Bash script: Avoid single quotes added to string |
1,503,604,290,000 |
This answer shows how to diff two strings - Using the diff command to compare two strings?
I try:
diff <( printf '%s\n' "tring1" ) <( printf '%s\n' "string2" )
The output is:
1c1
< tring1
---
> string2
This shows that the two strings are different.
I would like to know at which characters the two strings are differe... |
For your specific use-case, store the strings in files, and compare those with git diff:
$ echo tring1 > f1
$ echo string2 > f2
$ git diff --word-diff --word-diff-regex=. --no-index f1 f2
diff --git a/f1 b/f2
index e8ae123..d704b3b 100644
--- a/f1
+++ b/f2
@@ -1 +1 @@
{+s+}tring[-1-]{+2+}
This shows that the “s” char... | Show differences in strings |
1,503,604,290,000 |
I run git grep for the first time on a large tree (the Linux kernel).
This takes a long time to run. If I cancel with ctrl+C before it finishes, often it immediately shows a line it found.
Why did git grep not show the line immediately, when it found it?
$ rpm -q git
git-2.17.2-1.fc28.x86_64
|
git grep output is buffered by less. (In most cases. It can be changed using various configuration options, if you need to).
The reason I did not notice this, is that git grep does not show the less pager footer when there is less than one screen of output. However, the output is still buffered. (I can see that le... | git grep output is buffered. Why? |
1,503,604,290,000 |
I'd like to keep my keys secure, but also not have to enter a passphrase on every single git invocation, when I want to run several commands in quick succession. I've researched this, and found that ssh-agent/keychain/etc. go too far convenience-vs-security-wise to my liking. Something like xyz git pull would be perfe... |
This is exactly what ssh-agent does.
where xyz checks if my key is decrypted, and if it isn't - asks for my passphrase
You don't need any xyz. Just start ssh-agent at the start of your session (for example in ~/.bashrc):
[ -z "$SSH_AUTH_SOCK" ] && eval $(ssh-agent -t 5m)
And configure your ssh client to add the key... | Sudo-like utility for ssh, or at least git in particular? |
1,503,604,290,000 |
I accidentally typed git init in my home directory which caused git to start tracking everything in my home directory and I need to remove it.
Is there a git command or a way to terminate git tracking everything in my home directory?
Thanks.
|
Git creates a folder .git in the top-level directory it tracks. The only thing you need to do is to remove that folder using rm -Rf .git.
| Terminating Git |
1,503,604,290,000 |
If I have a local ikiwiki on my laptop I need a "repository" directory (mywiki.git - a bare repository), a "scrdir" (myiki a git repository) and a place where the produced html files go ("destdir") to run it properly from a web browser locally.
However if I also want to work with a text editor and git on the command ... |
I have successfully used ikiwiki with 0+ repositories.
0..2 are single-user, so I have not run into conflicts (yet).
0..1 were just an experiment with ikiwiki.
Here is what I tried:
0 repositories - compiling manually,
1 repository (working directory == srcdir) without upstream - compiling manually,
2 repositories (w... | Why do I need 3 git repositories for ikiwiki if I want to commit locally |
1,503,604,290,000 |
I was trying to set up a git server. I set up the SSH server successfully, and now I was trying to set up an anonymous git service, but it's not working properly.
I copied the sample systemd service file from the git book https://git-scm.com/book/en/v2/Git-on-the-Server-Git-Daemon, changing only the paths to where I ... |
Just encountered this myself a few minutes ago and came across your question in the process of figuring it out.
Remove the trailing slash from the directory path at the end of your git daemon command in your systemd file. This seems to cause an issue with the whitelist as seen in the error shown in /var/log/syslog.
Ex... | git-daemon says 'not in whitelist' even if git-daemon-export-ok exists |
1,503,604,290,000 |
What happens if two git pull command are run simultaneously in the same directory?
|
git does file locking to prevent corrupting the repository. You may get messages like
error: cannot lock ref 'refs/remotes/origin/develop': is at 2cfbc5fed0c5d461740708db3f0e21e5a81b87f9 but expected 36c438af7c374e5d131240f9817dabb27d2e0a2c
From github.com:myrepository
! 36c438a..2cfbc5f develop -> origin/develo... | Running two git commands in parallel |
1,503,604,290,000 |
A common problem game developers have with the Unity3D engine and Git is that Unity and Git fight for whether an empty directory should exist or not - Git doesn't care, Unity3D will keep making git trackable *.meta files for empty directories. Basically means devs have to manually find and delete directories and meta ... |
You probably meant
dirs_to_check="$(echo "$changed_files" | xargs dirname | sort -u)"
A simple solution, unless you have thousands of directories, is simply to try to rmdir each directory and ignore the errors.
find . -depth -type d -exec echo rmdir --ignore-fail-on-non-empty {} +
Change . to the top of the directo... | Detect and remove empty directories from list |
1,503,604,290,000 |
I'm getting a 'permission denied' error on a git alias. It works with root but not my user account:
$ andy@ubuntu:/usr/local/bin$ sudo git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
$ andy@ubuntu:/usr/lo... |
There's an entry in your $PATH pointing to a directory that you can't access, and you're using a version of git earlier than 1.7.10.1.
When you run git lg git first does some setup, including adding an entry to the copy of the $PATH that it is using. Then it tries to run the command git-lg, so that a command would ov... | Git Alias 'Permission Denied' |
1,503,604,290,000 |
I sometimes use characters such as ! and $ in commit messages, they need to be manually escaped, but not if you use single quotes like this git commit -m 'My $message here!'. I tried to write a function to make gc and all text following as the message, but no luck in making it use single quotes. Everything I've tried,... |
TL,DR: don't.
What you're asking for is impossible. When you write gc My $message here, this is an instruction to expand the value of the variable message and use the expansion as part of the arguments of the function.
You can do something like what you want by tricking the shell with an alias that adds a comment mark... | Run `git commit -m` with single quotes in zsh |
1,503,604,290,000 |
I'd like to search all git tracked files that 1. has an .hs file extension and 2. contain the word import in any lines.
I've tried to use git ls-files -z | xargs -0 rg -g '*.hs' "import" however unfortunately if you pass an explicit list of files to rg it seems to ignore the -g glob flag.
I could potentially use grep ... |
I hope I'm not misreading the question. If you want " to search all git tracked files that contain the word import in any lines", that should be:
git ls-files -z | xargs -0 grep -l import
If you only want to search in *.hs files, then:
git ls-files -z '*.hs' | xargs -0 grep -l import
| How can I search only git tracked files with a specific file extension? |
1,503,604,290,000 |
I can test if the current directory like this:
[[ $(git rev-parse --is-inside-work-tree 2> /dev/null) == true ]] && echo yes
..but how can I do the same for a directory that is not the current working directory?
|
Just use the -C global option to git. Doing this, and simplifying your code (why would you parse the output to reconstruct information that's directly encoded in the return status?):
directory=. # or wherever
if git -C "$directory" rev-parse --is-inside-work-tree >/dev/null 2>/dev/null; then
echo yes
fi
| How to check if a directory is in a git working tree when that directory is not the current working directory? |
1,503,604,290,000 |
I am trying to delete some local git branches with
git branch -D $(git branch | grep 'RTL-1[1|2|3]' | xargs)
However I am getting this kind of error
error: branch 'RTL-1114_branch_name1?[m' not found.
error: branch 'RTL-1224_branch_name2?[m' not found.
error: branch 'RTL-1225_another_branch?[m' not found.
For some r... |
You’ve probably got git and/or grep configured to always output using colours; in that case,
git branch -D $(git branch --color=never | grep --color=never 'RTL-1[123]')
should work.
You can use git’s own pattern-matching:
git branch -D $(git branch --color=never -l '*RTL-1[123]*')
To avoid this in future, you should... | Mac OS xargs adds '?[m' at the end of line |
1,503,604,290,000 |
I'm curious if anyone has a way to automatically generate a different set of --exclude-dir flags for grep for each different codebase that you work in.
Because in one project, I'll never want to search in the output/ dir, and in another, I'll never want to search in the checkpoints/ directory.
Since there are often a ... |
The following script works for me
#!/bin/bash
if [ -r .grepignore ]; then
while read -r line; do
if [[ "$line" =~ '#' ]] || [[ "$line" =~ ^$ ]]; then
continue
fi
EXCLUDE="$EXCLUDE --exclude-dir=\"$line\""
done < .grepignore
fi
eval grep -r "$EXCLUDE" '"$@"'
The script che... | Have custom grep exclude dirs for each project |
1,503,604,290,000 |
I wrote a ansible role to automate installing etckeeper.
I discover that git will complain if I haven't configured user.email. In some circumstances, git commits will fail. This includes automatic commits to etckeeper when installing a package, potentially causing the install to fail. So I have to add a task for th... |
UPDATE: should be fixed in the next release (1.18.8).
https://etckeeper.branchable.com/todo/requires___96__user.email__96___be_set_under_undocumented_circumstances/
After hitting this a couple of times, I felt I needed to look at the source code.
git absolutely requires an "email address" for its commits. Without o... | ansible role: Why do I have to set user.email in etckeeper? |
1,503,604,290,000 |
I found a lot of ways to deal with the whitespace problem in Git, but all of them require some sort of action on the user side: configure Git to ignore ws changes, setup a pre-commit hook with warning, or just configure the editor to remove them automatically. But is there a way to simply ignore whitespace changes on ... |
You can't really do this sanely. You can't modify the content of a commit; you can only create new commits. Even if this were possible, it would break git: the commits on the server would be unrelated to the history stored in local developer repositories, and nothing would ever work. You really need to perform this... | Git Server: ignore whitespace changes in new commits |
1,503,604,290,000 |
I am working on the atom-editor-git PKGBUILD in the AUR, hoping to turn it into an Atom equivalent to the gvim-git PKGBUILD. See the gvim-git PKGBUILD updates its package version whenever it is run to the latest release of gVim, e.g., if I was to run it right now it would build a package for gVim 7.4.1236. The atom-ed... |
Atom uses the stable branch for its stable release builds, so to find the latest tag for a release you need to check that branch:
$ git describe --tags stable
v1.4.2-1-ge9db64c
To retrieve the corresponding tag, keep everything up to the first -:
$ git describe --tags stable | cut -d- -f1
v1.4.2
To get the version w... | How do I get git to give me an acceptable pkgver for Atom which I can use to check it out? |
1,428,000,262,000 |
I've downloaded the latest kernel sources:
git clone git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
cd linux-stable
git tag -l | less
and picked v3.9.1.
git checkout -b v3.9.1
git branch --set-upstream v3.9.1 origin/master
, pulled the distribution:
git pull
and ran:
make kernelversion
which... |
When you run
git branch --set-upstream v3.9.1 origin/master
you're telling git that you want your local v3.9.1 branch to track master on the remote. To get the remote v3.9.1 you can simply do
git checkout v3.9.1
If you're using the repository you created previously, you'll need to delete your own v3.9.1 branch first... | How to select the tag of the latest non-unstable/release candidate version? |
1,428,000,262,000 |
I want to write a script that will run
git diff --name-status master..<BRANCH>
but when I run this:
for i in $(git branch | grep -v master); do
echo $i;
done
I get echo one directory because git branch echo asterisk (I have one directory in current directory)
* <SELECTED BRANCH>
Why * is expanded and how can I ... |
Unquoted variables and command substitutions like $i or $(git …) apply the split+glob operator to the string result. That is:
Build a string containing the value of the variable or the output of the command (minus final newlines in the latter case).
Split the string into separate fields according to the value of IFS.... | Why asterisk in command result in for loop is expanding? |
1,428,000,262,000 |
I want compress all the git repositories on my computer (say in ~). I.e., for each directory {}, that contains directory or file (in case of submodules) named .git, I want to execute git gc --aggressive --git-dir={}.
I tried the following:
/bin/find /c/libs/boost/ -name '.git' -print -exec git --git-dir=dirname {} gc ... |
You're passing the word dirname as the argument to --git-dir.
With GNU or FreeBSD find, the -execdir action executes a command in the directory containing the matching file.
find /c/libs/boost/ -name '.git' -execdir git gc --aggressive \;
If your find command doesn't have -execdir, you can pass the .git directory as ... | apply specific command for each git repository |
1,428,000,262,000 |
I have some repos which are both in SVN and Git. My username is guyfawkes, and in my home directory I have folder www which contains all my repos. In this directory I also have file update.sh:
[guyfawkes@guyfawkes-desktop ~/www]$ cat update.sh
cd /home/guyfawkes/www
cd crm
echo "upd crm"
svn up
echo "update crm comple... |
The problem is you are trying to update from github which requires an ssh
key. Either create a dedicated ssh key without a password on your server
and add it to your github account or use the http-readonly uri to update
your repository:
git pull --mirror https://github.com/account/repository.git
| Crontab with SVN and Git |
1,428,000,262,000 |
I'm using a bash script to create a Git hook. I want to run a process (linting) against files I'm committing. I only want to run the process if the files actually exist (in other words, not consider files taht were deleted from in my commit). I tried this
CHANGED_FILES=$(git diff --cached --name-only | grep ".j... |
The problem with your script is that CHANGED_FILES is a scalar variable, not an array.
Try:
CHANGED_FILES=( $(git diff --cached --name-only | grep ".js$") )
i.e. add parentheses around the $(git...) command substitution.
Note that this is subject to the usual shell word splitting, so if there is any chance(*) that th... | In bash, how do I create an array of committed files that still exist on my file system? |
1,428,000,262,000 |
With the big move from master as the default branch name for git in many projects (e.g. to main in GitHub), some of the scripts and configurations assuming it as the default name will be broken. For example, if you have setup aliases to save time typing some of the git commands:
[alias]
com = checkout master
r... |
Git doesn't have a concept of a default branch. A repository may contain many independent lines of development (e.g., a maintenance and a development branch), none of which are more special than any other. The importance of branches and how they're to be merged is up to the owner of the repository.
What you think of... | How to operate on default branch within gitconfig and shell scripts |
1,428,000,262,000 |
I am about to try and install the git package.
In Synaptic, in the dependencies tab, it writes:
Breaks: bash-completion (<1:1.9-1)
Breaks: bash-completion [italicized]
I have the latest version of bash-completion offered by the repository installed (version 1:2.8-1ubuntu1).
I have read that git comes with some adapt... |
You're seeing this Synaptic bug, which causes it to misparse “Breaks” dependencies. The two packages aren't actually incompatible.
You should be able to install git with some other tool, for example sudo apt-get install git in a terminal. It won't have any impact on the bash-completion package. I can confirm that ther... | Git package breaks bash-completion? |
1,428,000,262,000 |
Currently I have this and it works as expected if I use it like addcommit 'test commit' but if I use it as addcommit test commit it only sees the first word test. Ideally I'd like to have the functionality of addcommit test commit and it executing git add . && git commit -m 'test commit'
addcommit()
{
git add .... |
Replace "$1" with "$*".
And in order to be completely safe against IFS traps:
addcommit()
{
local IFS=' '
git add . && git commit -m "$*"
}
This is a case where an alias could help, and allow the commit message to contain any character:
alias addcommit='_m=$(fc -nl -0); git add . && git commit -m "${_m#*addcomm... | bashrc function, git commit -m with spaces |
1,428,000,262,000 |
I have been working a local repository synced with a GitHub repository.
Recently our GitHub repository has a newly created branch release.
Locally, I first run git checkout release, which seems successful, and says:
Branch release set up to track remote branch release from origin.
Switched to a new branch 'release'
... |
A merge on git pull indicates that the local and remote branches have diverged. That means that there are new commits in both branches (local and remote) since the last time they were in sync.
To integrate the new remote commits into your local branch without a new merge commit, kill your current git command, then run... | After checkout a new remote branch, why does pull tells me that it will merge? |
1,428,000,262,000 |
When I run
find -maxdepth 1 -type d -name 'iptp*' -execdir bash -c "ls {}" \;
I get a listing of all dirs named iptp*
When I run
find -maxdepth 1 -type d -name 'iptp*' -execdir bash -c "git status {}" \;
I get
fatal: Not a git repository (or any parent up to mount parent )
Stopping at filesystem boundary (GIT_DI... |
With -execdir, the command is run in the directory containing the match, i.e. the parent directory of the directory whose name starts with “iptp”.
You could instead look for .git with a path matching iptp*:
find -maxdepth 2 -type -d -name .git -path "*/iptp*/*" -execdir git status \;
| find dir with wildcard and run git status not working |
1,428,000,262,000 |
I am using a script to update my system:
cd /opt/
chmod 600 /opt/updater/.ssh/.pk
ssh-agent bash -c 'ssh-add /opt/updater/.ssh/.pk; git stash; git pull origin master'
/opt/updater/bin/updater.sh
My problem is that if /opt/updater/.ssh/.pk us not readable or the ssh-key was changed, the process will get stuck like th... |
The trick is to have ssh immediately fail if it tries to do password authentication (thus always only do public/private key authentication).
You could set the environment variable GIT_SSH to a shell script to extend the normal ssh command to include -o "PasswordAuthentication no", but if you don't normally access the... | ssh-agent and timeout |
1,428,000,262,000 |
I am trying to create a personal sync system for my project. I don't want to use something like dropbox, bittorrent sync, owncloud etc for various reasons.
At the moment, I have my computers setup to use encfs and git over a usb drive. Where I have a local unencrypted folder on each computer and the encrypted encfs ... |
For backing up files between two computers, rysnc is usually the way to go. If the files may be changed on either computer, unison might be a better way to go. You can run either regularly via a cron job or manually when needed (more robust for unison). Of course you will have to set up a password-less ssh login to th... | Automatically backup usb drive to computer |
1,428,000,262,000 |
When using Git VCS, I execute all of the git commands on the directory that contains a .git repository. I want to execute a git-pull through an SSH trigger but how do I define the path to the repository to perform the action on?
|
If you set the GIT_DIR environment variable, git will use it as a path to the repository.
In general, you can start a subshell like this:
(cd /some/other/directory/; git pull)
The subshell will have its own current directory and environment variables.
| Execute a command in a different path |
1,428,000,262,000 |
I noticed that in git version 1.8.3.1 (provided by CentOS 7) it seems this command is not working:
git cat-file -t -- "5378198ea7a83f5fa9bb3ba17f51be3a6ffbecc1:README.md"
(Obviously specify a correct git hash and an existing file at that revision)
This is the standard error:
usage: git cat-file (-t|-s|-e|-p|<type>|--... |
git cat-file used to have a strict check on the number of arguments to it, which meant that -- couldn’t be used. The check happened before options were parsed, which is why you get the usage output immediately, with no indication of why the arguments are invalid.
This was removed in May 2015; the first release contain... | git cat-file: when was introduced the "--" escape parameter? |
1,428,000,262,000 |
It's hard to make it clearer than the title.
I upgraded from debian 9 to 11 yesterday, and somehow my git package got dumped on the way.
So naturally I tried to reinstall it this morning. One problem, it asks me for a dependency that doesn't exist.
~ sudo apt install git ... |
Your system references the git-core Ubuntu PPA, which is where it’s trying to install git from. Ubuntu PPAs shouldn’t be used with Debian; in this particular case, you’re using a 22.04 PPA which relies on Ubuntu 22.04 packages, including a newer version of libc6 than is available in Debian 11.
You can force the instal... | I can't install a package because it asks a dependency version higher than the available one |
1,428,000,262,000 |
I have installed git on Debian 10.
Why do I have two identical git binaries in two different places?
/usr/lib/git-core/git
/usr/bin/git
These are identical files, have same sha256sum. But they are not hardlinks.
They are same files existing in two copies.
Seems strange. I wonder what's the purpose.
|
This particularity has been upsetting some for years.
BTW, you'll read as part of the answer from Jonathan Nieder that upstream does hardlink but Debian does not ship that way since they can't be sure both path are on the same filesystem.
ArchLinux faced this problem years ago.
| git binaries installed from debian package |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.