With command-line jgit, how to checkout a single file back to its git version? - jgit

For example jgit diff returns 1 changed file, I want to revert it back to the versioned version. In normal git I would just
$ git checkout path_to_file
I tried
$ jgit checkout origin/master -- path_to_file
but nothing changes, no error, no nothing and the file remains
UPDATE
I tried:
$ jgit checkout origin/master -- path_to_file - no change
$ jgit checkout -- path_to_file - no change
$ jgit checkout path_to_file - error: error: pathspec path_to_file' did not match any file(s) known to git.
$ jgit clean - wants to clean untracked files, not untracked changes
$ jgit checkout -f origin/some_other_branch; $ jgit checkout -f origin/master - hoping that this would squash the changes, but then simply the 2nd command fails because "changes would be overwritten"
...and many more things I don't remember any more ofc :)

Actually I just tried, and jgit checkout -- path_to_file works for me:
~/Development/Eclipse/jgit (master)
$ org.eclipse.jgit.pgm/target/jgit --version
jgit version 4.9.0-SNAPSHOT
$ org.eclipse.jgit.pgm/target/jgit status
On branch master
$ echo "dummy" > pom.xml
$ org.eclipse.jgit.pgm/target/jgit status
On branch master
Changes not staged for commit:
modified: pom.xml
$ org.eclipse.jgit.pgm/target/jgit checkout -- pom.xml
$ org.eclipse.jgit.pgm/target/jgit status
On branch master

Related

Compiling: conflicting types for 'sigset_t'

I'm trying to compile the wazuh manager. I've done the following:
$ sudo apt-get install gcc make git libc6-dev
$ mkdir ossec_tmp && cd ossec_tmp
$ git clone -b stable https://github.com/wazuh/wazuh.git ossec-wazuh
$ cd ossec-wazuh
$ sudo ./install.sh
This gives me an error as such:
In file included from /usr/include/asm/signal.h:26:0,
from /usr/include/linux/signal.h:5,
from /usr/include/linux/aio_abi.h:32,
from engines/afalg/e_afalg.c:43:
/usr/include/asm-generic/signal.h:92:3: error: conflicting types for 'sigset_t'
} sigset_t;
I then went and tried compiling without shared library only the agent by running:
sudo make -C src DISABLE_SHARED=1 TARGET=agent
This seem to give the exact same error. Anyone able to assist me here to debug?
I can recommend you to follow the manager installation guide of our documentation.
As I can see you want to install the server in a folder called 'ossec_tmp', I recommend you to create the folder and after that following the guide, when you launch
./install
It will ask you for the path where you want to install the service.
Here is a link to the documentation:
https://documentation.wazuh.com/current/installation-guide/installing-wazuh-server/sources_installation.html
Hope it helps.

Building Riak on CentOS from source

I'm trying to build Riak 2.1.3 from source on CentOS 7. The build fails with Uncaught error in rebar_core.
The sequence of steps is the following:
Install Basho version of Erlang with kerl:
$ ./kerl build git git://github.com/basho/otp.git OTP_R16B02_basho8 R16B02-basho8
$ ./kerl install R16B02-basho8 ~/erlang/R16B02-basho8
$ . ~/erlang/R16B02-basho8/activate
Clone Riak git repo and build
$ git clone https://github.com/basho/riak.git
$ cd riak
$ git checkout riak-2.1.3
$ make rel
For this process I'm getting error:
[juriy#dbvm riak]$ make rel
Using rebar.config.lock file to fetch dependencies
./rebar -C rebar.config.lock get-deps
Uncaught error in rebar_core: {'EXIT',
{undef,
[{crypto,start,[],[]},
{rebar,run_aux,2,
[{file,"src/rebar.erl"},{line,212}]},
{rebar,main,1,
[{file,"src/rebar.erl"},{line,58}]},
{escript,run,2,
[{file,"escript.erl"},{line,747}]},
{escript,start,1,
[{file,"escript.erl"},{line,277}]},
{init,start_it,1,[]},
{init,start_em,1,[]}]}}
I also tried to build Erlang from the source, with the same result. Here's the exact list of commands:
wget http://s3.amazonaws.com/downloads.basho.com/erlang/otp_src_R16B02-basho8.tar.gz
tar zxvf otp_src_R16B02-basho8.tar.gz
cd OTP_R16B02_basho8
./otp_build autoconf
./configure && make && sudo make install
Please see my answer to your GitHub issue.

Pushing files to a BitBucket repo doesn't work

I'm new to git and would like to get started using bitbucket.org as a place to create a private repository. This can then be uploaded to the staging server using a service like ftploy.com as I understand.
I am following a tutorial on WPBeginner.com to set up a staging environment for my WordPress local website which I am developing. I set up git on the mac, ran git init on the theme folder and then added all the files using git add .
After that I made a first commit using git commit -m "message here" So far the process appeared to work. No feedback in the terminal though? I then added the line
git remote add origin https://bitbucketusername#bitbucket.org/bitbucketusername/repositoryname.git
Replacing bitbucketusername with mine and repository name with mine. Attempting to push the files to the bitbucket repository resulted in this error however:
error: --all can't be combined with refspecs
usage: git push [<options>] [<repository> [<refspec>...]]
-v, --verbose be more verbose
-q, --quiet be more quiet
--repo <repository> repository
--all push all refs
--mirror mirror all refs
--delete delete refs
--tags push tags (can't be used with --all or --mirror)
-n, --dry-run dry run
--porcelain machine-readable output
-f, --force force updates
--force-with-lease[=<refname>:<expect>]
require old value of ref to be at this value
--recurse-submodules[=<check>]
control recursive pushing of submodules
--thin use thin pack
--receive-pack <receive-pack>
receive pack program
--exec <receive-pack>
receive pack program
-u, --set-upstream set upstream for git pull/status
--progress force progress reporting
--prune prune locally removed refs
--no-verify bypass pre-push hook
--follow-tags push missing but relevant tags
If you have any thoughts on why this may be the case I would appreciate it
You should provide us the command you used to do your git push, but my guess is you did something like this:
git push --all origin master
As git is telling you, this can't be used that way. Here you are asking git to push everything to origin but then you specify a branch (the <refspec>), so it is confusing.
Either push all like this:
git push --all origin
or just your master branch like this:
git push origin master

How to Upgrade and Deploy WordPress Install as a Git Submodule?

I am using a WordPress directory struture similar to Mark Jaquith's WordPress Skeleton, which has WordPress in a separate directory from the content as a submodule:
/content
/wp
/local-config.php
/wp-config.php
/index.php
I also use git and post-receive hooks to push my code changes up to my live server. It all works great except for when I try to upgrade WordPress and push that up to the live server.
This is how I setup the repo on my local machine and the remote server:
Local Machine
cd /www
git init .
git submodule add git://github.com/WordPress/WordPress.git wp
git commit -m "Add Wordpress submodule."
cd wp
git checkout 3.5
After checking out the tag, I get a warning from git about being in a 'detached HEAD' state. Since I don't plan on making any commits to WordPress, I don't think that should be an issue.
cd ..
git commit -am "Checkout Wordpress 3.5"
Remote Server
git init --bare
cat > hooks/post-receive
#!/bin/sh
GIT_WORK_TREE=/home/public git checkout -f
chmod +x hooks/post-receive
git remote add web ssh://user#server/home/private/code/wordpress.git
git push web +master:refs/heads/master
I get this error:
No refs in common and none specified; doing nothing.
Perhaps you should specify a branch such as 'master'.
fatal: The remote end hung up unexpectedly
error: failed to push some refs to 'ssh://userserver/home/private/code/wordpress.git'
After some googling, it looks like I can use this command to sync up the master branch up to the server (I have no idea how this works)
git push web +master:refs/heads/master
This doesn't help me though because I don't want to track master, I want to track a release tag, 3.5. Some more googling got me to this command:
git push web +3.5~0:refs/heads/master
To upgrade the submodule, I do this:
cd wp
git fetch && git fetch --tags
git checkout 3.5.1
git push web +3.5.1~0:refs/heads/master
Am I doing this correctly? All the tutorials I see for this just have git push web and they're done. Most don't even cover upgrading the submodule. This does work but I don't feel comfortable using this weird push syntax if I don't have to.
How do I push this detached HEAD state up to the server correctly?
I've also tried this using a branch with git checkout -b mywp 3.5 but when it comes time to upgrade, I don't know how to bring in the new 3.5.1 tag into my mywp branch.
Asked this on WP Answers, but it might be more appropriate here.
On the remote server try:
git submodule update --init --recursive
This will update all your submodules recursively
You can also issue:
git fetch --tags
This will update your local tags fetching updated list from the central remote repo.

How to clone the latest stable branch to a dir via github?

I want to clone the latest stable version of WordPress from Github, via a shell script. It is simple to get the unstable master branch:
git clone git://github.com/WordPress/WordPress.git
But how can I get the highest numbered stable release via a script, not manually checking out the code. E.g., using deployment shell script or deployment tool such as Fabric.
Edit: I clarified the text to better indicate the intent that I meant how to do this from a script, not manually.
Clone from git and change to the WordPress directory
git clone git://github.com/WordPress/WordPress.git
cd WordPress
Then list out the branches..
git branch -r
This gives something like...
origin/1.5-branch
origin/2.0-branch
...
origin/3.4-branch
origin/HEAD -> origin/master
origin/master
Check out the branch you want...
git checkout 3.4-branch
Branch 3.4-branch set up to track remote branch 3.4-branch from origin.
Switched to a new branch '3.4-branch'
Here's what I actually ended up doing, which is included in a Fabric fabfile I have on Github:
git clone git://github.com/WordPress/WordPress.git .
git checkout $(git describe --tags $(git rev-list --tags --max-count=1))
It clones the repo like normal, then does some shell magic to find the latest tagged version of WordPress (Which is where the stable branches live.)
Can you try a git checkout master ?
git branch -r will show you all the remote branches
git checkout --track <local_branch> <remote>/<remote_branch> will setup a local branch that is tracking the remote branch in order to push or get new updates.
you can use this command after git clone
git checkout stable

Resources