Problems syncing a local directory with an existing GitLab repository

G

green_yallowa

Guest
Brief description of the situation


I'm using Jekyll with GitLab pages. I want to have 2 repositories, one with all the configuration files of jekyll, and another one with just the html generated, so that I can access my webpage on gitlab pages.

My problem


I can't just clone the repository because it creates a new subdirectory, and inside that directory, I can't run jekyll new . because it says the directory has content.
Ok, so what I do is first create the site, but then I want to sync that directory with a remote repository on gitlab.

What I tried to do


[email protected]:~/mysite$ git remote add origin [email protected]:unveiled_adri/jekyll_config.git
fatal: not a git repository (or any of the parent directories): .git



This was the first thing, but it says that is not a git repository, so I run this

[email protected]:~/mysite$ git init
Initialized empty Git repository in /home/vagrant/mysite/.git/



Ok no problems. We continue...

[email protected]:~/mysite$ git add *
The following paths are ignored by one of your .gitignore files:
_site
Use -f if you really want to add them.



[email protected]:~/mysite$ git commit -m "test"
[master (root-commit) 0498c60] test
Committer: Vagrant Default User <[email protected]>
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly. Run the
following command and follow the instructions in your editor to edit
your configuration file:

git config --global --edit

After doing this, you may fix the identity used for this commit with:

git commit --amend --reset-author

9 files changed, 273 insertions(+)
create mode 100644 404.html
create mode 100644 Gemfile
create mode 100644 Gemfile.lock
create mode 100644 _config.yml
create mode 100644 _posts/2019-10-06-welcome-to-jekyll.markdown
create mode 100644 _posts/2019-10-07-Another-awesome-post.markdown
create mode 100644 about.markdown
create mode 100644 first_page.markdown
create mode 100644 index.markdown


All seems to add the commit

[email protected]:~/mysite$ git remote add origin [email protected]:unveiled_adri/jekyll_config.git
[email protected]:~/mysite$


I found that this command is said that adds the remote repository when you didn't clone

[email protected]:~/mysite$ git push origin master
To gitlab.com:unveiled_adri/jekyll_config.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to '[email protected]:unveiled_adri/jekyll_config.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.



Now it says that I need to fetch first (I don't really know what is fetch, but I do it)

[email protected]:~/mysite$ git fetch
warning: no common commits
remote: Enumerating objects: 14, done.
remote: Counting objects: 100% (14/14), done.
remote: Compressing objects: 100% (9/9), done.
remote: Total 14 (delta 1), reused 0 (delta 0)
Unpacking objects: 100% (14/14), done.
From gitlab.com:unveiled_adri/jekyll_config
* [new branch] master -> origin/master



No problems with the fetch I guess, and now I try to push again to the master branch

[email protected]:~/mysite$ git push origin master
To gitlab.com:unveiled_adri/jekyll_config.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to '[email protected]:unveiled_adri/jekyll_config.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.



It continues saying that it needs a pull, so now I try to pull the changes from the master branch to the local repository...

[email protected]:~/mysite$ git pull origin master
From gitlab.com:unveiled_adri/jekyll_config
* branch master -> FETCH_HEAD
fatal: refusing to merge unrelated histories


And now is says this...I'm completely lost.
I only used git before but with visual studio so It was graphical, but never used git with commands. I more or less know the concepts, so I learned how to clone, push and pull but with a clean directory and repository. I tried now this, but this is different, with an existing directory and with an existing repository, and I want both to sync.
I really don't care about the contents of the remote repository, because the contents I want to be there are the ones I have in the jekyll site directory. So you can suggest a solution that deletes with remote files, I don't mind.
I've been messing a lot with git but as I said, I'm really lost and confused, and I would like to understand what it's happening.
Thanks in advance

Continue reading...
 
Top