In order to progress with my development projects, I needed to use a source control software, the best one for this is Git so I installed a Git server in one of my machines. I ran across some issues which I detail in the below steps list:
- Install Git in the server machine
- sudo apt-get install git
- Add a new user for git in the server.
- sudo useradd git
- passwd git
- Make sure to grant this user ssh access by editing /etc/ssh/sshd_config to add the line AllowUsers git
- sudo vi /etc/ssh/sshd_config
- sudo service sshd restart
- Test that you can ssh into the server with the user git from the client machine
- ssh git@server.name
- create repository in server
- sudo su git
- mkdir $HOME/gittestrepository1.git
- cd $HOME/gittestrepository1.git
- git init –bare
- create repository in client and add some files which simulate the code you wish to store in the git repository
- mkdir testgitclientrepo1
- cd testgitclientrepo1
- echo this is code>codefile1.txt
- git init
- git add .
- git commit -m “comitting code” -a
- Push the changes to the server
- git remote add origin ssh://git@katana.fritz.box/home/git/gittestrepository1.git/
- git push origin master
- Anybody who wishes to download the code can do so with the following command
- git clone git@katana.fritz.box:/home/git/gittestrepository1.git
- After they modify the code, if they want to push it into git, they must identify themselves at least the first time.
- git config –global user.email “rogemadrid@gmail.com”
- git config –global user.name “Roge Retropie”
- git commit -m “modification from retropie” -a
- git push origin master
- When working in a distributed team, when you want to update your local codebase in the morning with the changes done by your colleagues, run
- git pull origin master
- If you have done changes to your local code which you wish to discard and overwrite your local copy with the latest server copy
- git checkout — .
- git pull origin master
Yeah, but… do you even stash? Stashing is king. And dont forget unresolved conflicts when merging. Life is good!