Restart Git repo Xcode 4.3.2 - objective-c

For different changes I made in my project, I need to restart Git repo and start with a new fresh version with the current project. How can I achieve this?
Many thanks

fire up your terminal:
go to project
cd myPath/MyProject
delete the current repo on your disk - your git repo = RIP
rm -Rf .git
init a new repo
git init
add your project to the new git repo
git add .
commit
git commit -a -m "init Project XY"
check if the repo is o.k
git status

What you want to do is create a new empty branch without any history. That way you start fresh but still have the option to return to your previous content. Inside the git repository, enter these commands:
git symbolic-ref HEAD refs/heads/<branchname>
rm .git/index
git clean -fdx
After that you are in the same situation as with an empty repository (i.e. start adding and commiting files) except that the history still exists in your old branches.
Note that all files you don't have in your old version will be permanently removed.

Related

Docksal and Git shallow issue

When I set up a docksal project, it uses git and the project folder ends up with a remote:
https://github.com/docksal/boilerplate-drupal9-composer.git
I then add another remote, to the repo for the codebase I am developing.
The problem is that the clone done by docksal was shallow, and when I try to push to my repo the push is rejected because of the shallow setting (the shallow file in .git)
Feel free to drop the .git folder and initialize a fresh git repo in the project folder Docksal created.
In case you'd prefer to inherit the boilerplate git repo commit history, you can always clone the repo directly:
git clone https://github.com/docksal/boilerplate-drupal9-composer.git drupal9
cd drupal9
fin project start

gitlab runner doesn`t work on a specific project

I registered 11 projects of GitLab runner. Runners of each project work fine except 1 project. First time I registered runner of this project, it works.
But after I commit/push some changes, an error occurs and failed job.
I saw some solutions that upgrading the git version solved a problem, but I don't think so. Because all of the runners work fine except this project.
Server OS: CentOS 7
git: 1.8.3.1
First time registered runner
>Running with gitlab-runner 11.9.2 (...)
on (...)
Using Shell executor...
Running on localhost.localdomain...
Initialized empty Git repository in /home/gitlab-runner/(...)/.git/
Clean repository
Fetching changes with git depth set to 50...
Created fresh repository.
From https://gitlab.com/(...)
* [new branch] master -> origin/master
Checking out (...) as master...
Skipping Git submodules setup
$ echo "> gitlab-ci started"
> gitlab-ci started
$ cd /home/(..)
$ echo "> git pull started"
> git pull started
$ git pull
remote: Total 0 (delta 0), reused 0 (delta 0)
Already up-to-date.
Job succeeded
Second commit/pull, then
>Running with gitlab-runner 11.9.2 (...)
on (...)
Using Shell executor...
Running on localhost.localdomain...
Reinitialized existing Git repository in /home/gitlab-runner/(...)/.git/
Clean repository
Fetching changes with git depth set to 50...
fatal: remote origin already exists.
fatal: git fetch-pack: expected shallow list
ERROR: Job failed: exit status 1
edit. here is my .gitlab-ci.yml
stages:
- deploy
deploy_to_master:
stage: deploy
script:
- echo "> gitlab-ci started"
- cd /home/www/dir
- echo "> git pull started"
- git pull
- echo "> permission set"
- chmod 707 -R ./data/
- chmod 707 -R ./plugin/nice/
- chmod 707 ./favicon.ico
- echo "> server reload(=httpd -k graceful)"
- systemctl reload httpd
only:
- master
tags:
- tags
There are a few options to fix this. The problem is the version of git on your runner is too old. And sometimes you can't update git on the runner.
Options to fix:
Upgrade to a newer version of git on the runner.
In .gitlab-ci.yml, use the option to git clone:
variables:
GIT_STRATEGY: clone
Configure Gitlab, change Git strategy for pipelines of the project to "git clone".
3.1. In the Gitlab web gui,
3.2. go to your project,
3.3. then: "Settings -> CI / CD -> General pipelines".
3.4. Change the options for:
"Git strategy for pipelines" to: "git clone"
"Git shallow clone" to: 0
Centos 7 ships with git version 1.8.3.1 . This version doesn't support commands like git fetch-pack . To fix this problem, you could update git on your server from the IUS repository.
update git on Centos 7 to version 2 from third-party IUS repo
$ git --version
git version 1.8.3.1
sudo yum -y install https://packages.endpointdev.com/rhel/7/os/x86_64/endpoint-repo.x86_64.rpm
sudo yum install git
You can go around this problem without upgrading git at all:
1. Clone Strategy
Set in .gitlab-ci.yml:
variables:
GIT_STRATEGY: clone
Now every change you make will trigger re-cloning the project, avoiding the need of the problematic git fetch-pack command.
2. Manually Remove Project Directory (not recommended)
Remove manually the build directory from gitlab-runner server, so it will have to clone it again.
For project testgroup/testproject, run:
careful with rm commands!
rm -rf /home/gitlab-runner/builds/UwnzuxxL/0/testgroup/testproject
Notice that after builds directory you have a random string that will be different from this example.
Check value in your project's CI/CD settings on gitlab.com. If there is any value in 'git shallow clone' remove it and save changes. Now your pipeline will work as expected.
I had a similar issue, and I had to update Git. Centos 7 comes with git-1.8.x which has limitations around gitlab-ci.
Upgrade your git, based on this guide.
I made a new project and, finally, it works fine. I don't know why the other one didn't work. If the same problems occurs like mine, don't get too serious: Just make a new gitlab project. It is good for your mental well-being.
rm -fr /home/gitlab-runner/(...) , clean then exists repository

update the version in package.json without clean git working directory (without a task runner like Gulp)

When running a: npm version prepatch I get the error: "Git working directory not clean." And then a list of files that aren't committed yet.
However, I'd like to do this prerelease to test some stuff locally using a private npm registry. Meaning that I don't have to commit the files just yet using Git.
Is it possible to update the version in package.json without clean git working directory?
From the npm version documentation at https://docs.npmjs.com/cli/version:
If run in a git repo, it will also create a version commit and tag. This behavior is controlled by git-tag-version (see below), and can be disabled on the command line by running npm --no-git-tag-version version. It will fail if the working directory is not clean, unless the -f or --force flag is set.
I'm not 100% certain whether you just need --no-git-tag-version, or if you'll also need the --force flag.
You can use git stash.
E.g.
git stash
npm version patch
git stash pop
This will reset your working directory temporarily (remove uncommitted changes). Then you can run npm version {major|minor|patch}. Afterwards, using git stash pop will re-apply your uncommitted changes to your working directory.
Tutorial: https://www.atlassian.com/git/tutorials/saving-changes/git-stash#stashing-your-work
Try to commit first
git add . && git commit -am "new version"
and then
npm version patch

Git directly commit file to git and/or gitlab

So, here's my use case:
I'm attempting to develop an internal Mac app for the non-developers on my team, to edit some of my game's parameters. Ideally, the application will be able to recreate the necessary config files and directly commit/push them to my gitlab instance, which would trigger a CI build.
I know I could programmatically clone my repo to their machine and then edit it programmatically and commit the changes, but I'm trying to avoid having to have each user who is only editing a few files cloning 2+GB of code.
Any suggestions how to commit directly to a remote repo? In this case, both the user and my server can be considered "trusted". Thanks!
That would look like those config file could be in their own (very small) git repository, and kept in the main repo as a submodule.
However, once a submodule has been pushed back, a hook should make sure the parent repo update its submodule reference (git submodule update), and add+commit the new SHA1 of said submodule which was just pushed.
Otherwise, the parent repo wouldn't realize that its submodule has changed.
That also means the parent repo should declare that submodule as following the latest SHA1 of master branch:
git submodule add -b master /url/to/submodule
For something as restricted as this a single-repo solution would also work:
Make a configs-only branch:
git checkout --orphan configs
rm all but configs
git add -A
git commit -mconfigs
git checkout main
git push server configs
In the config-editor repos:
git init configrepo
git remote add server u://r/l
git fetch server configs
git checkout -t server/configs
# work work, then
git commit -am "new configs"
git push
As part of your build,
git pull -Xtheirs configs

How to import local git repository into svn?

I am working on local git repository and I need to push my local git into existing svn repository. My git repository is pure local git repository, it was not init using git svn clone.
How can I import this local git repo into svn?
Preferably I'ld like to keep the git history being imported into SVN.
Currently the SVN repository is structure as:
https://svnrepohost
/branches
/tags
/trunk
/projectA
/projectB
/newProject
What I need it is to import my git repository into the https://svnrepohost/trunk/newProject above, assuming the newProject folder is empty.
I have finally solved this problem by the following steps:
Setup appropriate project folder in svn to be imported to, for example http://svnrepo/svn/trunk/newProject
Create a new git-svn repository
git svn clone http://svnrepo/svn/trunk/newProject
Add the git repo that we want to import as remote to the new git-svn repo
git remote add origin ../original-git-repo
Pull all the data from original-git-repo
git pull origin master --allow-unrelated-histories
Rebase local repository against svn
git svn rebase
Commit the changes into svn
git svn dcommit
Clean up the remote
git remote delete origin
The easiest way to do this is to just svn import the Git directory. That will lose you your Git commit history, however.
First of all, make sure the .git directory won't be imported by setting the global-ignores in the Subversion config file. Open your ~/.subversion/config file (that'll be in something like C:\Users\username\.subversion\config on Windows), find the section starting [miscellany], and add a line directly underneath reading as below:
global-ignores = .git
(if you already have a line with global-ignores = that doesn't have a # in front of it, then just add .git to the end of that line.)
Next, run the below:
svn import <path-to-local-git-repository> https://svnrepohost/trunk/newProject
That should copy the contents of the local Git repository onto the server exactly where you want it.
You may use SubGit.
$ svnadmin create repo.svn
$ subgit configure repo.svn
...
CONFIGURATION SUCCESSFUL
Adjust '/tmp/repo.svn/conf/subgit.conf' file
and then run
subgit install "repo.svn"
to complete SubGit installation.
$ nano repo.svn/conf/subgit.conf #edit to set git.default.repository=path/to/your/bare/git/repository
$ subgit install repo.svn
I would also recommend you to create a bare clone of your Git repository and to specify path to it (in git.default.repository) instead of your original repository. I.e.
$ git clone --bare path/to/your/original/repository path/to/your/bare/git/repository
After "subgit install" command the repositories (repo.svn and repo.git) will be in continuos synchronization (triggered by pre-receive hook in Git [that starts on pushing to your bare repository] and pre-commit in SVN). To stop synchronization you may run
$ subgit uninstall repo.svn
git svn clone http://svnrepo/svn/trunk/newProject
git remote add origin ../original-git-repo
git fetch origin
git checkout -b lmaster remotes/origin/master
git rebase master
git svn rebase
git svn dcommit