So, I've tried setting up a gist under my own username on github:
https://gist.github.com/sdaau/771e0ca9b9f1fa17464373266400386f
... and I'm trying to clone, edit and push to this gist. I do not have 2-factor authentication (2FA) enabled in Your Profile/Edit Profile/Security (github.com/settings/security).
I would like to clone this repo, so when I push, I authenticate with my GitHub password, and not with a personal access token; and also I would like to avoid creating public keys for SSH access.
This is what I can observe so far:
cd /tmp/
$ git clone https://sdaau#gist.github.com/771e0ca9b9f1fa17464373266400386f.git yet_another_git_tute_gist
Cloning into 'yet_another_git_tute_gist'...
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), done.
Checking connectivity... done.
So, when cloning, even if I have my username specified in the HTTPS url, I'm not being asked for a password, the repository just gets cloned. This is an example of changes before push:
cd yet_another_git_tute_gist/
git config user.name sdaau
git config user.email sdaau#whatever
echo >> README.md # just add empty line
git add README.md
git commit -m 'testing'
# [master 0f958d5] testing
# 1 file changed, 1 insertion(+)
... and this is the push:
$ git push --all
Password for 'https://sdaau#gist.github.com':
remote: Invalid username or password.
fatal: Authentication failed for 'https://sdaau#gist.github.com/771e0ca9b9f1fa17464373266400386f.git/'
Would anyone know what am I doing wrong?
Oh well, after half an hour of re-cloning, changing and getting the push error, just as I was writing this question, eventually it succeeded:
$ git push --all
Password for 'https://sdaau#gist.github.com':
Counting objects: 5, done.
Writing objects: 100% (3/3), 246 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To https://sdaau#gist.github.com/771e0ca9b9f1fa17464373266400386f.git
b706450..0f958d5 master -> master
... so I'm guessing I wasn't typing my password right. Still, let's keep this Q/A online, as I didn't find an example exactly worded like this one (and had I found one, I would have probably tried a bit harder to enter the right password).
Note to self: remote: Gist does not support directories.
Related
So the background is this: I have an Xcode project that depends on a swift package that's in a private repository on github. Of course, this requires a key to access. So far, I've managed to configure CI such that I can ssh into the instance and git clone the required repository for the swift package. Unfortunately when running it with xcbuild as CI does, it doesn't work and I get this message:
static:ios distiller$ xcodebuild -showBuildSettings -workspace ./Project.xcworkspace \
-scheme App\ Prod
Resolve Package Graph
Fetching git#github.com:company-uk/ProjectDependency.git
xcodebuild: error: Could not resolve package dependencies:
Authentication failed because the credentials were rejected
In contrast, git clone will happily fetch this repo as seen here:
static:ios distiller$ git clone git#github.com:company-uk/ProjectDependency.git
Cloning into 'ProjectDependency'...
Warning: Permanently added the RSA host key for IP address '11.22.33.44' to the list of known hosts.
remote: Enumerating objects: 263, done.
remote: Counting objects: 100% (263/263), done.
remote: Compressing objects: 100% (171/171), done.
remote: Total 1335 (delta 165), reused 174 (delta 86), pack-reused 1072
Receiving objects: 100% (1335/1335), 1.11 MiB | 5.67 MiB/s, done.
Resolving deltas: 100% (681/681), done.
For a bit more context, this is running on CircleCI, set up with a Deploy key on GitHub, which has been added to the Job on CI.
Any suggestions about what might be different between the way Xcode tries to fetch dependencies and the way vanilla git does it would be great. Thanks.
For CI pipelines where you cannot sign into GitHub or other repository hosts this is the solution I found that bypasses the restrictions/bugs of Xcode around private Swift packages.
Use https urls for the private dependencies because the ssh config is currently ignored by xcodebuild even though the documentation says otherwise.
Once you can build locally with https go to your repository host and create a personal access token (PAT). For GitHub instructions are found here.
With your CI system add this PAT as a secret environment variable. In the script below it is referred to as GITHUB_PAT.
Then in your CI pipeline before you run xcodebuild make sure you run an appropriately modified version of this bash script:
for FILE in $(grep -Ril "https://github.com/[org_name]" .); do
sed -i '' "s/https:\/\/github.com\/[org_name]/https:\/\/${GITHUB_PAT}#github.com\/[org_name]/g" ${FILE}
done
This script will find all https references and inject the PAT into it so it can be used without a password.
Don't forget:
Replace [org_name] with your organization name.
Replace ${GITHUB_PAT} with the name of your CI Secret if you named it differently.
Configure the grep command to ignore any paths you don't want modified by the script.
This seems to be a bug in Xcode 11 with SSH. Switching to HTTPS for resolving Swift Packages fixes the issue:
So from this:
E29801192303068A00018344 /* XCRemoteSwiftPackageReference "ProjectDependency" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "git#github.com:company-uk/ProjectDependency.git";
requirement = {
branch = "debug";
kind = branch;
};
};
to:
E29801192303068A00018344 /* XCRemoteSwiftPackageReference "ProjectDependency" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/company-uk/ProjectDependency.git";
requirement = {
branch = "debug";
kind = branch;
};
};
Also, now that Xcode 12 is out, you can use that, where it's fixed.
In order to get private swift packages working with GitHub actions I had to add the following:
I had to add an SSH key to my secrets
On the xcodebuild step, I had to add the flag: -usePackageSupportBuiltinSCM
right before executing the xcodebuild step, I had to add the following run script:
- name: Add CI SSH Key
run: ssh-add - <<< "${{ secrets.YOUR_SECRET_SSH_KEY }}"
You can resolve this issue in a CI environment with Xcode 12 by adding your GitHub account to Accounts within Xcode.
Sign in with your GitHub account name and a personal access token you created on Github.
We are using Jenkins with Fastlane tools and when xcodebuild is invoked, it will use the access token to authenticate into the repos using HTTPS.
I had the same issue, the root cause for me is: the default github ssh key type is ed25519 ssh-keygen -t ed25519 -C "your_email#example.com".
But XCode doesn't support ed25519. Changed to RSA key works: ssh-keygen -t rsa -b 4096 -C "your_email#example.com"
https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent
You can see the error under XCode Preference > Accounts > Github
I was able to build with a package from a private repo in GitHub actions with HTTPS URLs by creating a .netrc file using the extractions/netrc#v1 action.
Build:
runs-on: macos-12
steps:
- uses: actions/checkout#v3
- uses: extractions/netrc#v1
with:
machine: github.com
username: user
password: ${{ secrets.SWIFT_PACKAGE_MANAGER_PAT }}
- uses: extractions/netrc#v1
with:
machine: api.github.com
username: user
password: ${{ secrets.SWIFT_PACKAGE_MANAGER_PAT }}
After this, xcodebuild will use the PAT when accessing the private repo.
I tried to use GITHUB_TOKEN, but it seems that it is restricted to the current repo only. So I created a PAT for my GitHub account and added that to the repo secrets.
I am using git on ubuntu.
git branch does not show the branches' names. I tried cloning different repositories, but again git branch does not show the branches' names.
I have also created a new repository and it is the same.
Example:
>git clone https://github.com/uber/pyro.git
Cloning into 'pyro'...
remote: Counting objects: 13342, done.
remote: Compressing objects: 100% (23/23), done.
remote: Total 13342 (delta 8), reused 0 (delta 0), pack-reused 13319
Receiving objects: 100% (13342/13342), 55.85 MiB | 5.34 MiB/s, done.
Resolving deltas: 100% (9814/9814), done.
>ls
pyro
>cd pyro
>git branch -a
>git branch -r
>git branch
>git status
On branch dev
Your branch is up to date with 'origin/dev'.
Adding another branch:
>git checkout -b branch1
Switched to a new branch 'branch1'
>git branch
>
I have also committed one time. and it is the same.
>GIT_TRACE=1 git branch
15:39:13.295464 git.c:344 trace: built-in: git branch
15:39:13.296121 run-command.c:640 trace: run_command: unset
GIT_PAGER_IN_USE; LESS=FRX LV=-c pager
>git --version
git version 2.17.1
>
>env -i git branch
WARNING: terminal is not fully functional
* devress RETURN)
>
I have tested the same commands on another laptop and it works. (I have also uninstalled git and reinstalled it. It doesn't help)
Any idea how to fix it?
This is not a complete answer, but based on a lengthy chat discussion, it looks like some kind of interaction with the pager.
The user's environment includes these variables (among others):
LESSOPEN='| /usr/bin/lesspipe %s'
LESSCLOSE='/usr/bin/lesspipe %s %s'
Those are the default settings on Ubuntu, so that shouldn't be causing a problem.
git branch produces no output.
GIT_PAGER=/bin/cat git branch produces the correct output.
I haven't yet figured out why the pager should be causing this problem, but since changing GIT_PAGER to /bin/cat is a workaround, that must be what the issue is.
Show local branches:
git branch
Since you are cloning from remote/origin branches, it will not displaying using git branch. you need to at least visit that branch by using git checkout. Review below git commands. I have created new branch hotfix-test and then used git branch
~/pyro (dev)
$ git checkout -b hotfix-test
Switched to a new branch 'hotfix-test'
~/pyro (hotfix-test)
$ git branch
dev
* hotfix-test
Checkout the current branch to existing other branch.
$ git checkout lax
Switched to a new branch 'lax'
Branch lax set up to track remote branch lax from origin.
~/pyro (lax)
$ git branch
dev
hotfix-test
* lax
Cloning steps and origin branches
~/desktop (master)
$ git clone https://github.com/uber/pyro.git
Cloning into 'pyro'...
remote: Counting objects: 13342, done.
remote: Compressing objects: 100% (23/23), done.
remote: Total 13342 (delta 8), reused 0 (delta 0), pack-reused 13319
Receiving objects: 100% (13342/13342), 55.85 MiB | 2.69 MiB/s, done.
Resolving deltas: 100% (9814/9814), done.
~/desktop (master)
$ cd pyro
desktop/pyro (dev)
$ git branch -a
* dev
remotes/origin/0.1.2-release
remotes/origin/0.2.0-release
remotes/origin/0.2.1-release
remotes/origin/HEAD -> origin/dev
remotes/origin/ast-char-rnn
remotes/origin/bnn-mnist
remotes/origin/causal-tutorial
remotes/origin/continuation-poutine
remotes/origin/continuation-with-indep
remotes/origin/cubo
remotes/origin/dev
remotes/origin/dice-elbo
remotes/origin/gh-pages
remotes/origin/glom-autoname
remotes/origin/hmc
remotes/origin/jit-integration-tests
remotes/origin/lax
remotes/origin/lax2
remotes/origin/maps-iei
remotes/origin/master
remotes/origin/mvn-sym
remotes/origin/mvncv
remotes/origin/nightmare-poutine
remotes/origin/nips-2017
remotes/origin/only-continuation-poutine
remotes/origin/only-parallel-enumeration
remotes/origin/paul-mh-12-1
remotes/origin/pcg
remotes/origin/pragmatics-example
remotes/origin/ps-semaphore
remotes/origin/pyro_GP
remotes/origin/recursion-scope
remotes/origin/regtest-1
remotes/origin/rejector-research
remotes/origin/revert-611-verlet-pr
remotes/origin/rsa-ccg-example
remotes/origin/sampling-hash
remotes/origin/snorkel-example
remotes/origin/trace-posterior-sample-fix
remotes/origin/tst
remotes/origin/vec-rand-module
~/desktop/pyro (dev)
$ git branch -r
origin/0.1.2-release
origin/0.2.0-release
origin/0.2.1-release
origin/HEAD -> origin/dev
origin/ast-char-rnn
origin/bnn-mnist
origin/causal-tutorial
origin/continuation-poutine
origin/continuation-with-indep
origin/cubo
origin/dev
origin/dice-elbo
origin/gh-pages
origin/glom-autoname
origin/hmc
origin/jit-integration-tests
origin/lax
origin/lax2
origin/maps-iei
origin/master
origin/mvn-sym
origin/mvncv
origin/nightmare-poutine
origin/nips-2017
origin/only-continuation-poutine
origin/only-parallel-enumeration
origin/paul-mh-12-1
origin/pcg
origin/pragmatics-example
origin/ps-semaphore
origin/pyro_GP
origin/recursion-scope
origin/regtest-1
origin/rejector-research
origin/revert-611-verlet-pr
origin/rsa-ccg-example
origin/sampling-hash
origin/snorkel-example
origin/trace-posterior-sample-fix
origin/tst
origin/vec-rand-module
See Also
Why is "git branch" silent in new repositories?
I have disabled the git pager for the git branch by using git config --global pager.branch false. Now I can get the git branch output. But we didn't figure out what is the pager problem. For the other commands like git diff, the same problem exists.
I have Ruby, RubyGems, and svn2git installed under 32 bit windows 7.
svn2git https://code.google.com/p/skyrim-plugin-decoding-project/ --rootistrunk --revision 1:1693 --authors ~/authors.txt --verbose
The above line returns the following error:
Running command: git svn init --prefix=svn/ --no-metadata --trunk=https://code.g
oogle.com/p/skyrim-plugin-decoding-project/
Initialized empty Git repository in e:/tes5edit/.git/
RA layer request failed: PROPFIND request failed on '/p/skyrim-plugin-decoding-p
roject': PROPFIND of '/p/skyrim-plugin-decoding-project': 405 Method Not Allowed
(https://code.google.com) at /usr/lib/perl5/site_perl/Git/SVN.pm line 310
command failed:
git svn init --prefix=svn/ --no-metadata --trunk=https://code.google.com/p/skyri
m-plugin-decoding-project/
I read something about svnadmin so I tried the following
svnadmin: E205000: Repository argument required
I don't know what the argument would be.
I have never used GitBash or any of these programs. I have no idea what the proper commands would be to resolve the issue. I am also new to Git and have very little experience with it.
git svn clone http://my-project.googlecode.com/svn/ \
--authors-file=users.txt --no-metadata -s my_project
The standard commands also give errors
E:\TES5Edit_Git> git svn init https://code.google.com/p/skyrim-plugin-decoding-p
roject/
Initialized empty Git repository in E:/TES5Edit_Git/.git/
E:\TES5Edit_Git [master]> git config svn.authorsfile ./authors.txt
E:\TES5Edit_Git [master +1 ~0 -0 !]> git svn fetch
RA layer request failed: PROPFIND request failed on '/p/skyrim-plugin-decoding-p
roject': PROPFIND of '/p/skyrim-plugin-decoding-project': 405 Method Not Allowed
(https://code.google.com) at /usr/lib/perl5/site_perl/Git/SVN.pm line 148
E:\TES5Edit_Git [master +1 ~0 -0 !]>
As long as it makes a repo I can push I don't care how I do it. However, I did not start with a standard setup in the beginning and no idea what I was doing. So I want the clone to start at commit 1 and consider root as master, and all commits that make any kind of folder, rename folders, move folders, delete folders, all of everything created as branches.
After asking some friends I realized I had been using the wrong URL.
svn2git http://skyrim-plugin-decoding-project.googlecode.com/svn/ --rootistrunk --revision 1:1693 --authors ~/authors.txt --verbose
That would have been the correct init statment
i am about to clone code from svn repo (on centos) using git svn clone -s svn://xxx, then it is interrupted for strange problems, the error message is as follows:
Following parent with do_switch
Successfully followed parent
Use of uninitialized value in concatenation (.) or string at /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi/SVN/Core.pm line 584.
Network connection closed unexpectedly: at /usr/libexec/git-core/git-svn line 2693
then i continue this clone process using
time git svn fetch -r HEAD
all the things seems goes well, and succeed to clone that svn repo at last:
W: -empty_dir: trunk/src/os/win32/ngx_gui.c
W: -empty_dir: trunk/src/os/win32/ngx_gui.h
W: -empty_dir: trunk/src/os/win32/ngx_gui_resources.h
W: -empty_dir: trunk/src/os/win32/ngx_shared.h
W: -empty_dir: trunk/src/os/win32/ngx_types.h
r4817 = 7b58fc00b5b8ebb0544053ecf63e53b28935f15b (refs/remotes/trunk)
Auto packing the repository for optimum performance. You may also
run "git gc" manually. See "git help gc" for more information.
Counting objects: 12449, done.
Compressing objects: 100% (12177/12177), done.
Writing objects: 100% (12449/12449), done.
Total 12449 (delta 9475), reused 0 (delta 0)
Checked out HEAD:
svn://svn.nginx.org/nginx/trunk r4817
real 0m9.630s
user 0m6.015s
sys 0m1.870s
the strange issue is that there is no tags in my local git repo which is cloned from svn repo:
[root#home nginx]# git branch
* master
[root#home nginx]# git tag // no tags at all:(
[root#home nginx]# svn ls svn://svn.nginx.org/nginx/branches | wc -l
7
[root#home nginx]# svn ls svn://svn.nginx.org/nginx/tags | wc -l
388
in fact there are 388 tags in the svn repo, so how to fix my local .git repo?
should i have to restart to git clone from the remote svn server?
i have tried many times, with the same problem:(
Basically git-svn doesn't support tags as Git tags. In order to convert SVN tags to Git tags you may use:
SubGit (+maybe svnsync if you have no access to the server with SVN repository)
git-svn + command for references update:
"git update-ref refs/tags/TAGNAME refs/remotes/tags/TAGNAME"
SmartGit, if you want some UI and not writing a script
But note: only the 1st and the 3rd solutions allow you to push tags to the server to be conerted to SVN tags. With git-svn you should use additional "git svn branch" command.
I have this local repo, I make changes and run:
git add .
git commit -m "message"
git push -u origin master
My github has two WebHooks set-up, one going to a http://requestb.in URL and another one going to a PHP executable script (755), in the same folder (accessible from outside).
The PHP script:
<?php echo `git pull origin master`;
// echo "works";
// echo `whoami` ?>
The commented test lines are working so this is my proof that the script path is OK and also the syntax.
However, after I push changes from local to github repo, I check files on the server but nothing happens, is obvious echo git pull origin master from my PHP script does nothing.
If I run this in a shell logged as a root (git pull origin master), the files are getting updated with the latest version from the repo.
Also, the second hook I have set-up, the one from requestb.in works as I can see the requests from github.
My folder on the server has the right permission, is accessible form the outside, I am desperate and I don't know how to get this working.
What is wrong, how can I make this working? How do I set-up the WebHook in the admin panel in github, or is it the PHP script, is there a permissions issue, what's wrong?! :O
Thank you.
Update after my 3 comments:
After dealing with it for couple more hours, I can clearly see that the WebHook doesn't really fire up the php file. If I run in shell logged as a root "php test.php" I get:
root#echo [/home/moove/public_html/dev/wert]# php hooh.php
remote: Counting objects: 5, done.
remote: Compressing objects: 100% (1/1), done.
remote: Total 3 (delta 1), reused 3 (delta 1)
Unpacking objects: 100% (3/3), done.
From github.com:chrisdemetriad/wert
* branch master -> FETCH_HEAD
Updating 0c67b85..89e4fdf
Fast-forward
XXX.php | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
root#echo [/home/moove/public_html/dev/wert]#
Which is what I need and the files on the server get updated. But if I don't do it manually, the files do not get updated and this must be because of the php script. My latest version that works:
<?php echo `git pull origin master`;