The URL is of the form:
user@my.site.com:project.git
git@git.droplet.com:my-project.git
The URL is of the form:
user@my.site.com:project.git
git@git.droplet.com:my-project.git
So you need a private remote git repository for collaborative, backup or convenience reasons. You have your local repository setup and now you want another repository in the cloud. Recently, a few moments ago, I started this task and here I am about an hour and a half later sitting a little frustrated and annoyed. Still not knowing whether my git remote is working seamlessly. So let me save you some time...
Has your server security measures / paranoia ever bitten you in the butt? Well good that means you're doing well.
As a wise server administrator you have installed fail2ban and denyhosts on your server and configured them with severe measures, such as max 3 retries for ssh attempts. Fail2ban scans log files for too many attempts from a specific IP of a specific protocol, so if there is even an inkling of a password brute force attempt on one of your hosted sites or over secure shell the offending IP will be banned in an instant. DenyHosts is similar but focuses primarily on thwarting ssh dictionary attacks. Now if you have ever gazed upon /var/log/auth.log.
You will know that our collective paranoia has some backing.
These are great tools and I was sent packing by fail2ban after 3 failed attempts, and my ssh session was cut short prematurely. Shame and I had set the lockout time to 600 hours or 25 days. If this ever happens to you on a static ip, you needn't worry, just wait the 25 days. Otherwise if you are on a dynamic ip as most home adsl services are on you can wait to get new details via DHCP or force new deets. Otherwise you can ssh into another machine somewhere on the interwebs and then ssh into your server from their. As fail2ban and denyhosts used iptables (linux firewall) you will use the following commands to unblock yourself...
iptables -L
to see the offending ip's and spot your own
iptables -D
taken from: HowtoForge
So yes great tools, but why was I locked out. Well I had created a user for the git repository, namely git. However when you first configure ssh (an inherent package of linux), you configure it in /etc/ssh/sshd_config
specifying the port, protocol, whether to permit root logins and also specify users to allow. After creating the git user, I forgot to do this and when the repository was being pushed locally to remote, after 3 attempts I was locked out. So REMEMBER TO ALLOWUSER IN SSHD_CONFIG. Oh AND REMEMBER TO RESTART SSH FOR CHANGES TO TAKE EFFECT.
cd ~/.ssh
//if exists id_rsa.pub
clip < ~/.ssh/id_rsa.pub
//else
ssh-keygen -t rsa -C "your_email@example.com"
ssh-add id_rsa
//enter passphrase (Remember to Remember)
clip < ~/.ssh/id_rsa.pub
don't know if this is entirely necessary...
adduser git
//userdel -r git, if you made a mistake
ftp or
scp ~/.ssh/id_rsa.pub gituser@server_ip:./
su git
cat id_rsa.pub >> /home/git/.ssh/authorized_keys
git remote add [shortname] [url]
git remote add origin git@server.co.za
git init --bare repo.git
git push [remote] [branch]
git push origin master
if it asks for a password you are doing it wrong, as you have set up ssh keys for that very reason, not using a password. You should just need that passphrase that you remembered.
Permissions of folder should be git:git and 775.
Sources:
Git Github is distributed version control. It is free and open source, made by Linus Torvalds.
It is different from previous version control techniques:
Git is for anyone who wants to track changes, it was designed by developers for developers but anyone wanting to track changes can use it. However Git is no good for:
go to: http://git-scm.com
download and install with Git Bash
Now open Git Bash and go to the folder where you want a new repository:
git init
git add .
git commit -m "Message"
git log
#single line per commit
git log --oneline
#show just 3
git log --oneline -3
#since
git log --since="2012-02-20"
#until
git log --until="2 weeks ago"
#author
git log --author="Name"
#Searching
git log --grep="test"
#difference of log
git log -p
#statistics
git log --stat --summary
#email format
git log --format="email"
#graph
git log --graph
#well formatted (works better on unix)
git log --oneline --graph --all --decorate
Other version control:
Git:
head is a pointer to the tip of the current branch in the repository
Shows current branch and all untracked files (changes not yet staged)
git status
#working directory
git diff
#staged differences
git diff --
#differences between branches
git diff master..sandbox
#Unstaged
#just delete the file
#staged differences
git rm <filename>
git commit -m "Message Delete"
git add <renamed>
git rm <old file>
git commit -m "Rename Message"
git mv <onefile.txt> <otherfile.txt>
git init
#skip add just commit
git commit -a
git checkout -- <Filename>
git reset HEAD <Filename>
git commit --amend -m "Amend Message"
git checkout <CommitSHA/Checksum> -- <Filename> #eg. git checkout 4d5shd6a -- test.php #or git checkout b47hsdf4 #Use: git log to get the SHA/Checksum
#stage and commit git revert <Commit SHA / Checksum> #no commit no stage git revert -n <Commit SHA / Checksum>
#USE WITH CAUTION - Changes position of HEAD git reset --soft git reset --mixed (default) git reset --hard
#test run git clean -n #force to run git clean -f
#in project/ .gitignore #if not there create #basic regs: * ? [aeiou] [0-9] *.php
#personal preferences specific to OS git config --global core.excludesfile /users/Username/.gitignore_global
git rm --cached <Filename>
#Place a small file in the directory, Git only tracks files not directories
Treeish: References part of a tree
Can Use:
git ls-tree <treeish> git ls-tree HEAD
#check branches git branch #new branch git branch sandbox #switching between branches git checkout master #create and switch branch git checkout -b master
git checkout -- <Filename>
git branch --merged
git branch -d <branchname>
git merge <branchname> #fast forwardn is not a true merge #no fast forward git merge --no-ff <branchname> #fast forward only git merge --ff-only <branchname>
git stash save "Stash Message" git stash list git stash show -p stash{0}
#default puts latest one in git stash pop #put specific git stash pop stash@{2} #pops but keeps in stash git stash apply
git stash list git stash drop stash@{1} #clear stash git stash clear
git remote
git remote add <name usually origin> <https address or ssl>
#push masterbranch to github git push -u origin master
#find project on git #go to folder you want it to reside git clone <https/ssl of project> <project name>
git push origin master #if tracking branch git push
git fetch origin #fetch and merge git pull origin
#push nothing to origin git push :<branch> #new way git push origin --delete <branchname>
many IDE's have this functionality built in to make it much easier
Git Official Tutorial