Share this page : facebooktwitterlinkedinmailfacebooktwitterlinkedinmail

I will use Git with bitbucket for version management of the configuration files, and some scripts, so in my scenario, it’s a single person team.

First, you needs to create a Repository on the bitbucket website, edit the permission, then create project,

Create a git repository

You can do this in the web interface, simply click the New button in the repository section. Note down the name of the repository. if you username is foo, repository is test, the full url for the repository will be

an alternative way is use git init command.

clone the repository to local folder

first create a folder for the user foo, I will choose foo which mirroring the username in the bitbucket. then in terminal CD to the foo folder, user following command to copy the folder from cloud to local:

git clone

Then go the folder and work on the project:

cd test

Add file to local and remote repository master

Then select files you want to push or use . to choose all files in current folder:

git add <file_name>
git add .

git commit -m "My first commit"

git push origin master

If you want to exclude files from git add ., you should create a file called .gitignore in the local project root folder, then add the file name in this text file in relative path format. E.g, if you want to ignore a file called note.txt, then add a line in the .gitignore like this: note.txt

Push file to branch


switch to the branch

git checkout <branch>

To prepare for working on <branch>, switch to it by updating the index and the files in the working tree, and by pointing HEAD at the branch. Local modifications to the files in the working tree are kept, so that they can be committed to the <branch>.

If <branch> is not found and you want to create one branch, use:


git checkout -b <new_branch>

-b <new_branch> : Create a new branch named <new_branch> and start it at <start_point>


If you have not pulled code from the repository first, use command:

git pull develop

Then select files you want to push or use . to choose all files in current folder:


git add <file_name>
git add .

Commit the change:

git commit -m "comment"

Edit files, add and commit. Then push with the -u (short for --set-upstream) option:

git push -u origin <branch_name>


Merge a branch

After developing the branch and testing, you want to merge the branch into the master.

First of all, switch to branch

git checkout master

Then, use command to merge

git merge <branch_name>

 Then you also need to commit and push.


To download a public repository to local folder, you use the git clone repository_url command.