Git is a versioning thing, where you can keep various versions of code you’re working on, and still get old copies. Other people who are working on the same code can’t overwrite what you’re working on, so you make fewer mistakes, especially if you’re working on multiple projects. Normally, people just send their code to GitHub, which is a commercial site where lots of people host their code projects. In this how-to, we set a private Git server up for people who want to keep all their code in house. You could also use Subversion to do something similar, but Git has some advantages.
Debian Git howto
We’re setting up Git and Gitlabs CE (free version) on a Debian Jessie server. Become root and do:
apt-get install curl openssh-server ca-certificates postfix select 'Internet Site' curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | bash Detected operating system as debian/jessie. Checking for curl... Detected curl... Running apt-get update... done. Installing debian-archive-keyring which is needed for installing apt-transport-https on many Debian systems. Installing apt-transport-https... done. Installing /etc/apt/sources.list.d/gitlab_gitlab-ce.list...done. Importing packagecloud gpg key... done. Running apt-get update... done. The repository is setup! You can now install packages. apt-get install gitlab-ce (almost 300M, so this might take awhile) gitlab-ctl reconfigure
Now you have to go the the url for your server at http://whatever.url.or.ip.to.your.server and it will ask you to change your password. This is for the ROOT user. Then you can login and create other users and projects.
Once you set up this remote server, go back to your LAPTOP and create a local directory that you want to code in, like /usr/src/someproject and init git, so on Linux do:
apt-get install git cd /usr/src/ mkdir someproject cd someproject vi test.sh #!/bin/bash echo "test" git init Initialized empty Git repository in /usr/src/someproject/.git/ git add . (this adds all your code files git commit -m "First commit" [master (root-commit) 77ee28f] First commit Committer: root <email@example.com> 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: git config --global user.name "Your Name" git config --global user.email firstname.lastname@example.org After doing this, you may fix the identity used for this commit with: git commit --amend --reset-author 1 files changed, 133 insertions(+) create mode 100755 test.sh git remote add origin email@example.com:root/someproject.git git remote -v origin firstname.lastname@example.org:root/voltage-tracker.git (fetch) origin email@example.com:root/voltage-tracker.git (push) git config remote.origin.receivepack /opt/gitlab/embedded/bin/git-receive-pack git config remote.origin.receivepack /opt/gitlab/embedded/libexec/git-core/git-receive-pack git config remote.origin.uploadpack /opt/gitlab/embedded/bin/git-upload-pack git config remote.origin.uploadpack /opt/gitlab/embedded/libexec/git-core/git-upload-pack