How to move existing project to a group - gitlab

I have three existing projects that I want to put in one group in GitLab.
I did the following steps:
Create a new group supi
Go to project A => Settings => Advanced => Transfer project => Select namespace => Group supi
(Now Project A's url moved from git#gitlab.com:myname/project-a to git#gitlab.com:mygroup/project-a)
I changed the url inside of my local copy from project A git remote set-url origin git#gitlan.com:mygroup/project-a
I thought that everything will work from here, however, when I call git pull from my local project A I get this:
Your configuration specifies to merge with the ref 'refs/heads/master'
from the remote, but no such ref was fetched.
What does it mean?
This is the content of my .git/config file:
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
url = git#gitlab.com:mygroup/project-a.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master

Found the issue, I had no files in the repository. Adding a readme.md made it work.

Related

connecting to bitbucket and github from the same .gitconfig

I have a locally hosted version of bitbucket, and a github account. I want to be able to connect to both easily. I tried this .gitconfig version, does not work seamlessly. What Am I missing? What should I put under user in both systems?
#Github (default)
Host gh
HostName github.com
User ?
IdentityFile ~/.ssh/id.pub
#Bitbucket (secondary)
Host bb
HostName stash.company.com
User ?
IdentityFile ~/.ssh/id.pub
In your local repo, a "remote" is defined to tell git what repository to go to when doing things like push and pull.
The default name is "origin".
So we enter commands like "git pull origin main"
The command "git remote -v" will show the "remotes you have defined, like this:
git remote -v
origin git#github.com:/.git (fetch)
origin git#github.com:/.git (push)
You can define another remote to point to a different remote repo:
git remote add
So if you add a remote and call it bborigin then
git pull bborigin main
would pull the main branch on remote bborigin
(I do not know if you will need special steps to set up authentication on the different remotes)
First, you need to put that in ~/.ssh/config
That means you can:
test your authentication with ssh -Tv gh or ssh -Tv bb
use those Host entries in SSH URLs with
git clone gh:me/myGitHubRepository
git clone bb:me/myBitBucketRepository
Second, a typical global .gitconfig (in $HOME\.gitconfig) would look like:
[alias]
st = status
lg2 = log --graph --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n'' %C(white)%s%C(reset) %C(bold white)- %an%C(reset)' --abbrev-commit
lg = !"git lg2"
br = branch
[user]
name = You
email = your#email.com
[core]
autocrlf = false
safecrlf = false
commitGraph = true
quotepath = false
longpaths = true
[rebase]
autostash = true
autosquash = true
[pull]
rebase = true
[protocol]
version = 2
[gc]
writeCommitGraph = true
[credential "helperselector"]
selected = manager-core
[credential]
helper = manager-core
manager = manager-core
[init]
defaultBranch = main
This assumes you have downloaded and installed GCM (Git Credential Manager), the credential manager which helps caching your credentials (username/password) for HTTPS URL.
Not mandatory in your case, though, if you stick to SSH URLs.

Rename git branch name on remote using PyGithub

How can I rename github remote branch using PyGithub python API ?
Reference from official PyGithub - https://github.com/PyGithub/PyGithub
https://pygithub.readthedocs.io/en/latest/apis.html
from github import Github
# using username and password
g = Github("user", "password")
# or using an access token
g = Github("access_token")
# get repo
r = g.get_organization('org').get_repo('name')
# Git reference of the branch that you wish to delete
src = r.get_git_ref("heads/source branch name")
# Create new branch from old branch
r.create_git_ref("refs/heads/new branch name", sha=src.object.sha)
# Delete old branch reference
src.delete()

GitLab CI test differences between master and branch with Node

Currently I am trying to test the differences between master and a branch on GitLab CI.
var branch = require('git-branch'),
gitDiffTree = require('git-diff-tree'),
path = require('path');
var branch = process.env.CI_BUILD_REF_NAME || branch.sync();
var repoPath = path.resolve(process.env.REPO || (__dirname + '/../.git'));
{
repoPath: repoPath,
gitDiffTreeOptions: {
rev: 'master..' + branch
}
}
Here is the important bits of code that I'm using. This works great locally, but when ran on GitLab CI it says fatal: bad revision 'master.. branch' both times the branch variable was populated with the same value. Any advice how to get this to work? It previously used to do rev: HEAD which didn't work great because it only tested the most recent commit in the branch not all of them together.
I had a similar issue (bad revision 'master' when running git diff master -- . and similar commands), and got it working as follows:
run git fetch origin master (from the pipeline)
when referring to the master branch, use origin/master rather than master
I suppose the way gitlab fetches the repository contents does not cause master to be a valid branch name locally. I'm not familiar enough with the guts of git to pinpoint exactly why.

fatal: 'user/test.git' does not appear to be a git repository

I created a repo in gitlab and set the user.name in a global way.
When I try to push my project, after inserting my password, I get the following error:
fatal: 'user/test.git' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
My .git/config:
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
url = git#gitlab.domain.tld:user/test.git
fetch = +refs/heads/*:refs/remotes/origin/*
output from "git remote -v:
origin git#gitlab.domain.tld:user/test.git (fetch)
origin git#gitlab.domain.tld:user/test.git (push)
What could be the problem?
Try using this:
git push https://username:password#gitlab.com/user/test.git
I've seen some issues in the newer versions of git that give me trouble when I don't specify the username and password every time. I'm sure there's a way around it but I haven't figured it out yet. Git recommends rolling back to older versions, but I'm sure there is a less drastic way.
In Settings you want to add with
git push https://yourusername:yourpassword#gitlab.com/user/test.git

gitolite emailprefix GL_REPO not expanded

I am using gitolite v2.2 on Ubuntu 12.04.
The GL_REPO variable does not get expanded for emailprefix.
In my gitolite.conf file I have this:
repo #all
config hooks.mailinglist = xxx#somewhere
config hooks.emailprefix = "[%GL_REPO] "
config hooks.emailmaxlines = 1000
...
repo testing
RW+ = #all
I am getting email when I push changes to the testing repo, but the subject line looks like this:
[%GL_REPO] branch master updated.
Is there a typo in my configuration, a setting I missed, or is this a problem in v2.2?
The substitution of the variable GL_REPO in gitolite.conf file is only documented in gitolite v3 (or 'g3') pages:
Admin conf
"git-config" keys and values
the conf/gitolite.conf file
For g2 (gitolite V2.x), it is only mentioned (and expanded) for gitolite hooks.
Upgrading to v3 is therefore the way to go, since it won't affect any of your existing bare repos: see the migration page.

Resources