How to sync git on ubuntu with existing github projects? - linux

I used mac github client to push my codes to my github account. On my Ubuntu linux computer I wan't to connect to github using the terminal so that it will automatically sync will all my projects on github. How would I do it? All the online help I have bumped in to so far only show how to clone an exiting git repository not how to connect to my github account and sync it.

git, the revision control system, doesn't know anything about Github, a website that keeps track of and hosts your git repositories for you. The concept of a Github account is totally alien to git, so you'll never be able to, say, browse all of the projects you own on Github with a git command. git only works on the level of individual repositories.
Github also provides a graphical client that handles both the git level stuff and the Github level stuff -- it understands what a Github account is, and will log in for you and display all of the repos associated with the account. It's also a fully featured git client that does a lot of work on the level of individual repos for you. However, this graphical client is currently only available for Windows and OS X, and is not available for Linux.
My own workflow on Linux is to use the github.com website plus the command-line git tool. To bridge the gap between Github and git, you need to git clone individual repos. Aside from that, you can do Github administrative tasks on the website, and you can work with individual repos with git on the command line.
If you don't like this work flow, you need to look at graphical git clients for Linux. I'm not sure if any exist that will do both git-level stuff and also interface with Github specifically and understand the idea of a Github account.
You could also theoretically try to run the Windows client in wine on Linux, but I would not recommend this approach except as a last resort.

First I don't know a program that automatically sync all my github repositories.
First you have to install git (if it has not been done already) tutorial
Than you should generate a rsa:key to be able to 'push' your repositories to github.
You can generate a rsa_key by following this tutorial notes ssh-add id_rsa should be ssh-add id_rsa.pub ....also you can name id_rsa as anything you want: like bran_rsa_key
You should post or add your rsa_key to git hub at this address. If you go to that link you will see that you already have some key for your Mac but nothing for your Ubuntu.
After installation you could install ungit if you're not that familliar with git

Related

Issue with authentication using Git Kraken and self hosted Gitlab

so I have a self-hosted Gitlab, I use Git kraken pro and git for windows to enable the LFS component.
I'm having the issue where when I push to my repository git kraken asks for authentication. (Username and password.) How ever I have no such issue when I pull the data, it will just do the job. And the same is for the LFS, I can pull but not push the data without a password.
Here is the set up:
I have not been successful in setting up the ssh keys at this point as it refuses to use them and I'm still trying to work that issue out.
I have pressed the "remember me" option for the pop up and that doesn't seem to work
I have set up the access token and that all works.
The GitLab ce is installed on a Linux OS and I am connecting to it via 4 windows PC's using git kraken (all on pro licenses).
Git lab CE is updated to the latest version and same for git Kraken
Obviously, the preferred method of connection to the git is SSH but it refuses to work. I have tried the git kraken's version of ssh and manually creating and installing the keys using cmd line.
When I enter the U/P to push the data it only works for that single push even if I don't restart git lab. Every single time I need to place a user name and password and this is tiresome.
What I'm asking is, how can I fix this? This is my first full-fledged self-hosted git, and I've learned things on the fly, I do have normal git experience but the set up for the self-hosted is a lot more involved compared to just using git itself.
The reason I am self-hosting is, cost. My repos are GB in size and I have many. So, I need to have my own set up to avoid having those kinds of costs.
How can this be fixed?
When I enter the U/P to push the data it only works for that single push even if I don't restart git lab. Every single time I need to place a user name and password and this is tiresome.
Double-check if your GitKraken is actually using an SSH URL (git#yourServer:user/repo), as a username/password should only work for HTTMS URL (https://yourServer/user/repo)
Check the SSH port is reachable from your windows:
curl -v telnet://yourServer:22
If it does not connect, double-check your Omnibus installation on Linux, making sure the SSH daemon is started and active, using the right sshd_config.
The OP Maize adds in the comments:
A complete reinstall and removal of setting in GitKraken solved the issue.
Previous uninstalled seems to of kept the settings, so when I removed those, it sorted itself out.

Use git server without git user

I have a remote linux machine with only one user.
I just set up git repos on it without a git user. But all the tutorials suggest me to use the git user. So right now I am using
git clone user#hostname:/path/to/git/directory/your_project.git
rather than :
git clone git#hostname:/path/to/git/directory/your_project.git
And it works fine.
If I use the git account, for each project I have to change permission for that project and change the config to share the directory.
Does using the setting up and using a git user have any advantage over using your user account on linux?
Not much, maybe convention - git automation tools and APIs might expect a git user, but I've never come across such a situation.
Sources: https://git-scm.com/book/en/v1/Git-on-the-Server-The-Protocols and https://www.digitalocean.com/community/tutorials/how-to-set-up-a-private-git-server-on-a-vps
The second one describes the creation of a git user, and then you get the URLs (over SSH, using a SCP-like syntax, as referenced in the first article's second method) to be git#server:.
You've essentially done the same thing but with whatever user instead of a user named git, so you get user#server:

how to set permission in Git?

I am new to Git and after I lots of searching I found that I must have set Linux permissions in my Git server.
But I want to know, is it possible to set permissions in Git?
I am working on a team about six people and I don't like to everyone on the team can access all the project for security reasons.
For example, If somebody in my team works on UI in my Store section I want to he/she have it's own branch but when he/she PULL the project with Git just have access to files and folders I let.
I have to add that I have my own Git server on a local network using Linux Debian and I'm using "SourceTree" as my GUI for Git and I have few experience on Git command line, so I need do it from GUI if possible.
Edited:
Does Git lab support permission like this: I have a repository that uses Laravel framework and I'd like to set permission for UI developers that only access views and PHP developers access some controllers not all the part of the controller in the project.
You can checkout GitLab: https://about.gitlab.com/ for this. Out of the box git does not support what you need/want.
No, Git doesn't manage this directly. Anyone with authentication credentials to the repository has access to the entire repository.
Traditionally, this is managed with third-party solutions, such as Gitolite, GitHub private repositories, and other systems.
In addition to other answers: if you want only certain parts of project to be accessible to each developer, you can use git submodules.
This is also preferable if project has logically and functionally separate parts. (Like front-end and back-end. )

import entire GitLab Cloud project to new GitLab instance

I have some projects set up on GitLab Cloud, complete with issues, wiki pages, etc. I've recently set up an internally hosted gitlab instance. I'd like to bring these projects over from GitLab Cloud to the internal GitLab instance.
Bringing over the git repos seems easy enough (change the remote and push), but I don't see how to bring over the wikis and issues.
In general it seems like this isn't possible. (There's a GitLab Feedback for it here.)
However, the project wiki's seem to be their own git repos, which you can see on the Git Access tab. While that doesn't solve issues/snippets, it gets you part of the way there.
I don't know how to transfer over issues as I have not had to do that yet, but passing over the wiki is not that difficult.
On your old gitlab instance you will notice two repositories for your project (let's pretend your wiki is oldproject), one will say something like oldproject.git and oldproject.wiki.git.
The general path to the repositories where you can see the names I am talking about (let's assume user-name is "myaccount") can be found here:
/home/git/repositories/myaccount/
or (if using the omnibus installer):
/var/opt/gitlab/git-data/repositories/myaccount/
I presume you already know how to transfer over oldproject.git. You do the exact same thing with the wiki, only you create a bundle file out of oldproject.wiki.git:
git clone http://gitlab-instance-ip/user-name/oldproject.wiki.git
cd oldproject.wiki
git bundle create oldproject-wiki.bundle --all
Now initialize your new project in gitlab...I presume you already know how to do that as you suggested in your question that you know how to import the files from your project over to the new instance without problem. Now repeat for the wiki:
git clone http://new-gitlab-ip/user-name/newproject.wiki.git
cd newproject.wiki
git pull /path/to/oldproject-wiki.bundle
git push -u origin master
I had a very similar problem to yours where I didn't see that anything was actually "pushed". When I went back to the gitlab project I noticed that it was in fact updated with the wiki. See here if you think it will help: Importing Gitlab Wiki to a new Gitlab Instance
Good luck!

Looking for implementing a centralized git repository... with a catch

The idea behind what I am wanting to do is to create a centralized server on a linux system. I understand how to set this up, and already have. Next I would like to set up git on a windows system, aka the client, which I understand is possible through msysgit, and gitextensions. The problem though is that I am wanting to integrate the windows client to be able to push and pull visual studio files but keep the repositories on the linux server. So in short my question is how to have a centralized server on linux for git, while the client on windows is able to push to this centralized server. Thanks in advance!
I solved my problem. What I wanted to do was to create a ssh connection between the server(linux) and the client (windows). I used tortoise git in this case with the git source control provider (visual studio integration). Just follow the steps within the link and anybody else who might have this problem will be set!
Links:
For tortoise setup: http://theswarmintelligence.blogspot.com/2009/11/windows-tortoisegit-client-for-linux.html
What's the catch here? This sounds like a completely standard use case. It's probably best to use SSH as a transport to push to the server. A couple of things to be aware of are:
You should create your centralized repository as a bare repository (i.e. one without a working tree)
If you have multiple users who will push to that repository, create a group for them on the Linux machine, and make sure that the permissions for the repository are appropriate, e.g.:
git init --bare --shared=group newrepository.git
chgrp -R developers newrepository.git
Or if you're going to have multiple repositories or need more sophisticated access control, you may want to look at using gitolite on the server.
On the client side, GitHub has a nice walkthrough for installing msysgit on Windows (and generating an SSH key) here:
http://help.github.com/win-set-up-git/
... and there are tutorials for gitextensions on its site.

Resources