Setting SSH Bitbucket/Git
Problem: Many developers, especial juniors, when using Git/Bitbucket, clone repository use HTTPS, but exist more better way – use SSH. Ok, but how it works? How we can configure it?
Solution: Follow the instructions step by step:
Step 1: Connect to SSH remote host:
Step 2: Generate SSH keys, via run next command:
Step 3: Open file id_rsa.pub in hidden ssh folder:
Copy contain of the file to Bitbucket account - Settings - SSH Keys. Create new key and paste contain of file id_rsa.pub. Save it.
Step 4: Let's return on our server and make new folder as project name (domain name):
Step 5: Change directory and moving from current folder to project folder:
let's initialization Git into folder:
add next setting into file:
[core] repositoryformatversion = 0 filemode = true bare = false logallrefupdates = true [remote "origin"] url = email@example.com:user_name/repo_name.git # replace this string on current project (use option SSH on Bitbucket/Git) fetch = +refs/heads/*:refs/remotes/origin/* [branch "master"] remote = origin merge = refs/heads/master
Step 6: Execute commands:
git fetch git checkout -t origin/master
Step 7: Check files in current folder using
ls -la. If files not found need execute:
git pull origin master
if we get project folder from Git repo in current folder e.g.
project_name_folder/project_name_folder/files, and we need
project_name_folder/files, need execute command for all content moving:
mv .[!.]* /home/u123456789/public_html/
If you get error
mv: cannot stat ‘.[!.]*’: No such file or directory
don't pay attention 🙂 Files was moved. Note: Use
pwd comand that output current folder.