What are we doing?
- Generating SSH keys and adding them to bitbucket
- Installing Git core on our web server
- Setting up a repository
- Pushing a project to a repository
Version control is an industry standard in development. It enables developers to work as a team and keep track of changes.
Generate SSH Keys and add to Bitbucket
Repeat this on all (Unix like) devices that will use the repository
From terminal, execute the following commands-
ssh-keygen -t rsa -b 4096 -C "[email protected]"
(enter to place in default directory)
(enter to skip password protection)
(enter again to confirm)
Show the public key we just generated
Copy this value, then visit Bitbucket
Create a free account, then navigate to Account -> Settings -> SSH Keys -> Add key
Create a repository and copy the Git origin (The format will be similar to [email protected]:myuser/myfirstrepo.git)
Installing Git and initialising a repository
Update repositories and install the Git core.
sudo apt-get update
sudo apt-get install git-core
Set some global variables
git config --global user.name "YOUR_NAME"
git config --global user.email "[email protected]"
Initialise a repository
Tell Git where the remote repository is
git remote add origin [email protected]:myuser/myfirstrepo.git
We can now see what files Git is tracking with the following command
If you’d like Git to ignore any of these file, add them to .gitignore
sudo nano .gitignore
Add files or filetypes to be ignored
ctrl + x then y to save
Add all uncommitted files
git add .
Commit with message
git commit -m “Initial commit”
Send the files off to the Bitbucket repository
git push origin master
That’s it! If everything went to plan you will no be able to see your commit at Bitbucket under repositories -> commits