Blog is moving

My blog is moving to http://victormendonca.com/blog/. If you are looking for a specific or older post you are in the right place Otherwise check out my new page for more up to date content.
Showing posts with label Git. Show all posts
Showing posts with label Git. Show all posts

Wednesday, October 11, 2017

How to Load GitLab Inside an Iframe

So you are trying to load GitLab inside another page via iframe, and you are not able to. Due to security reasons, this is default behavior for GitLab, and as per the project (see issue 2347, this will not change, and I agree).
However for some internal users this might not be the best approach, so here's how to enable it.
Browse to your install directory and go to your ‘nginx’ folder. If you are not sure where it is, with your GitLab instance running, use the following command (assuming you are using port 8888).
# netstat -anp | grep 8888
tcp        0      0 0.0.0.0:8888                0.0.0.0:*                   LISTEN      19761/nginx
Now use the PID to find where ‘nginx’ is running:
# ps -ef | grep 19761
root     19761  1029  0 13:12 ?        00:00:00 nginx: master process /opt/gitlab/embedded/sbin/nginx -p /var/opt/gitlab/nginx
Browse to the config folder and edit the ‘gitlab-http.conf’
# cd /var/opt/gitlab/nginx/conf

# vim gitlab-http.conf
Add the line proxy_hide_header X-Frame-Options;`` in thelocation /` code block
```http.conf location / { ## Serve static files from defined root folder. ## @gitlab is a named location for the upstream fallback, see below. try_files $uri $uri/index.html $uri.html @gitlab; }
proxy_hide_header X-Frame-Options;

Comment the line `proxy_hide_header X-Frame-Options;` if present

```http.conf
location @gitlab {
    ## If you use HTTPS make sure you disable gzip compression
    ## to be safe against BREACH attack.


    ## https://github.com/gitlabhq/gitlabhq/issues/694
    ## Some requests take more than 30 seconds.
    proxy_read_timeout      300;
    proxy_connect_timeout   300;
    proxy_redirect          off;

    proxy_set_header   X-Forwarded-Proto $scheme;
    proxy_set_header   Host              $http_host;
    proxy_set_header   X-Real-IP         $remote_addr;
    proxy_set_header   X-Forwarded-For   $proxy_add_x_forwarded_for;
    proxy_set_header   X-Frame-Options   SAMEORIGIN;
    #proxy_hide_header X-Frame-Options;

    proxy_pass http://gitlab;
  }
Restart GitLab
# gitlab-ctl restart
ok: run: logrotate: (pid 31748) 1s
ok: run: nginx: (pid 31752) 0s
ok: run: postgresql: (pid 31757) 1s
ok: run: redis: (pid 31766) 0s
ok: run: sidekiq: (pid 31774) 0s
ok: run: unicorn: (pid 31786) 0s
That should be it!!!

Friday, November 7, 2014

How to Export/Import a GitLab Project

Important note: Please make sure you have a backup. I'm not a git expert and I have only tried this once
1- Clone the project
$ git clone http://[user]:[password]@[server]/[namespace]/[project].git
2- cd into the new created directory and create a bundle
$ git bundle create [project].bundle --all
3- Create a new project on the new server UI
4- Clone the new empty project
$ git clone http://[user]:[password]@[server]/[namespace]/[project].git
Initialized empty Git repository in /home/mendonca_v/Git/[project]/.git/
warning: You appear to have cloned an empty repository.
5- Change into that new project
$ cd [project]
6- Pull the bundle into that project
$ git pull ../common-impl/common-impl.bundle master
Note: When you do 'git status' no changes will be shown
$ git status
# On branch master
nothing to commit (working directory clean)
7- Push the contents to the new server
$ git push -u origin master

Monday, November 3, 2014

How to Add an Existing Folder on Your Computer to a New Git Repo

This is a simple and quick tutorial on how to add an existing folder (and files) on your computer to a new git repo.
1- Create your project online (like Bitbucket or GitHub)
2- Then cd into the folder where your files are and initialize it
$ git init
Initialized empty Git repository in /home/victor/Sync/BitTorrentSync/victor/www/.git/
3- Add all your files to be tracked (if you have anything that you want to exclude, you might want to do that with .gitignore now)
$ git add *
4- Commit with a initial message
$ git commit -m "My initial commit"
[master (root-commit) 652fc1a] My initial commit
 1942 files changed, 41072 insertions(+)
 create mode 100644 Arri/ARRICAM Checklist Project/ARRICAM ST CHECKLIST.doc
 create mode 100644 Arri/ARRICAM Checklist Project/k4.44256.0.jpg
 create mode 100644 Arri/ARRICAM Checklist Project/k5.42387.0.jpg
 create mode 100644 Arri/ARRICAM Checklist Project/k5.42388.0.jpg
...
 create mode 100644 wazem.org/sub.sites/Koken/photo.spheres
 create mode 100644 wazem.org/sub.sites/Koken_Installer.zip
 create mode 100644 wazem.org/sub.sites/Koken_Installer/koken/index.php
5- Add the remote location (example below is for Bitbucket)
$ git remote add origin git@bitbucket.org:[user]/[my-repo].git
6- Push the files
$ git push -u origin master
Counting objects: 2054, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2035/2035), done.
Writing objects:   1% (41/2054), 4.41 MiB | 844.00 KiB/s
You should see the following when it’s done
Total 2054 (delta 219), reused 0 (delta 0)
To git@bitbucket.org:[user]/[my-repo].git
 * [new branch]      master -> master
Branch master set up to track remote branch master from origin.