Bitbucket is a source code hosting service. It allows you to store your projects' source code and share it with others or keep it private. Bitbucket projects can be hosted in either Mercurial or Git revision control systems.
In this example, I will try to explain how to start a project using Mercurial revision control software and Ubuntu.
In this example, I will try to explain how to start a project using Mercurial revision control software and Ubuntu.
Sign up to Bitbucket
Create a repository
Install mercurial
Open a terminal
sudo apt-get install mercurial
Add your credentials to your machine
Create the file ~/.hgrc in your home directory with the following contents.
[ui]
username = Name Surname <[email protected]>
ssh way (Optional)
Open a terminal and generate your ssh key.
ssh-keygen
Install xclp.
sudo apt-get install xclip
Copy ssh key to clipboard.
xclip -sel clip < ~/.ssh/id_rsa.pub
Go to Bitbucket -> Manage account -> SSH keys -> Add key and paste your ssh key.
Clone your empty newproject
hg clone ssh://[email protected]/accountname/newproject
Create a file and mark the commit
echo "# This is my README" >> README.md
hg addremove
hg commit -m "First commit. Adding a README."
Push changes
hg push https://accountname@bitbucket.org/accountname/newproject
ssh way (Optional)
hg push ssh://[email protected]/accountname/newproject
Ignore files from push
To ignore files from the push, create .hgignore file in your projects root directory, with the following contents.
# use glob syntax.
syntax: glob
.hgignore
private_file.php
*~
In this way, you protect private_file.php, all backup files (ending with ~) and .hgignore file as well.
Strip accidental commits
It is a common mistake to push a commit that contained personal files.
To delete such a commit visit the repository page in Bitbucket.
Go to Commits and copy the commit hash.
Then go to repository Administration -> Strip changesets -> Paste the hash -> Preview and Confirm Strip.
Finally, go to Commits to verify it's removal.
To delete such a commit visit the repository page in Bitbucket.
Go to Commits and copy the commit hash.
Then go to repository Administration -> Strip changesets -> Paste the hash -> Preview and Confirm Strip.
Finally, go to Commits to verify it's removal.
Strip commit locally
To enable strip, add the following lines to ~/.hgrc
[extensions]
hgext.mq =
Then, in a terminal at your projects root directory, enter the following command with the commit_hash you want to remove.
hg strip -r commit_hash