Posts Tagged git

Configure Ubuntu to work as GO web server

Картинки по запросуI’m often creating go apps or services using Digital Ocean droplets with Ubuntu, that’s why I decided to create a script to automate configuration process.

 

The script is doing following:

  1. Installs and configures firewall (ufw, allows only ports 80, 443 & 22)
  2. Installs git (required by go)
  3. Installs mysql and secures it with mysql_install_db
  4. Installs the latest version of GO (1.7.5), configures go environment (PATH, GOPATH)
  5. Installs go application from public git repository, yours or my demo (development for private is in progress) with ‘go get’
  6. Configures go app to work as a service (add config into /etc/init.d), starts the service
  7. Installs and configures nginx to work as proxy for go app

Script can be started directly from github:

bash <(curl -s https://raw.githubusercontent.com/bykovme/webgolangdo/master/preparegolangapp.sh)

Check the script and find more information here: https://github.com/bykovme/webgolangdo

, , , , , , , , , , , , , ,

Leave a comment

Using standard command “go get” for private golang packages on gitlab.com

I’m keeping my projects privately on gitlab.com and want to use for some of my golang packages standard “go get” command instead of using git clone/pull. When I’m trying to use standard commands I’m getting the error

go get gitlab.com/bykovme/my_package_here
# cd .; git clone https://gitlab.com/bykovme/my_package_here.git /home/bykov/gopath/src/gitlab.com/bykovme/my_package_here
Cloning into '/home/bykov/gopath/src/gitlab.com/bykovme/my_package_here'...
fatal: could not read Username for 'https://gitlab.com': terminal prompts disabled

As I’m using SSH keys to access the git repository, the following command solves the issue giving possibility to use standard go packages commands

git config --global url."git@gitlab.com:".insteadOf "https://gitlab.com/"

You can check if it was applied using the following command

cat ~/.gitconfig

The output of the command above should be like the text below

[url "git@gitlab.com:"]
    insteadOf = https://gitlab.com/

The command

go get gitlab.com/bykovme/my_package_here

is working now.

PS. The same solution is working for github.com

, , , , , , , ,

Leave a comment

Delete local and remote branches, sync deleted branches

Show all the branches (local and remote) tracked in the local git repository:

git show-branch --all

Delete local branch:

git branch -d local_branch

If remote branch was deleted, it is still tracked locally, to remove from local tracking do the following:

git fetch -p

The command will delete (-p – prune) locally tracked branches which do not exist remotely

,

Leave a comment

How to reset local git repository

If you need to reset local git repository, it cannot be done with “git pull”, the following git command should be used:

git fetch --all
git reset --hard origin/master

Pay attention to the fact that all your local changes will be disregarded. Change “master” to the branch you need, if it is required.

, , , ,

Leave a comment