Menu
×
   ❮     
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP C C++ C# AWS W3.CSS HOW TO BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS DSA TYPESCRIPT ANGULAR ANGULARJS GIT POSTGRESQL MONGODB ASP AI R GO KOTLIN SWIFT SASS VUE GEN AI SCIPY CYBERSECURITY DATA SCIENCE INTRO TO PROGRAMMING INTRO TO HTML & CSS BASH RUST TOOLS

Git Tutorial

Git HOME Git Intro Git Install Git Config Git Get Started Git New Files Git Staging Git Commit Git Remove and Move Git Tagging Git Stash Git History Git Diff Git Blame Git Help Git Branch Git Merge Git Workflow Git Best Practices

Git and GitHub

GitHub Get Started Git What is SSH? GitHub Add SSH GitHub Set Remote GitHub Edit Code Pull from GitHub Push to GitHub GitHub Branch Pull Branch from GitHub Push Branch to GitHub GitHub Flow GitHub Pages Git GUI Clients

Git Contribute

GitHub Fork Git Clone from GitHub GitHub Send Pull Request

Git Undo

Git Revert Git Reset Git Clean Git Amend Git Rebase Git Reflog Git Recovery

Git Advanced

Git .gitignore Git .gitattributes Git Large File Storage (LFS) Git Signing Commits/Tags Git Cherrypick & Patch Git Bisect Git Merge Conflicts Git CI/CD Git Hooks Git Submodules Git Worktree Git Remote Advanced

Git and Bitbucket

Bitbucket Get Started Bitbucket Add SSH Bitbucket Set Remote Bitbucket Edit Code Bitbucket Branch Bitbucket Pages Bitbucket Fork Git Clone from Bitbucket Bitbucket Send Pull Request

Git and GitLab

GitLab Get Started GitLab Add SSH GitLab Set Remote GitLab Edit Code GitLab Branch GitLab Pages GitLab Fork Git Clone from GitLab GitLab Send Pull Request

Git Cert

Git Certificate

Git Reference

Git Glossary

Git Exercises

Git Exercises Git Challenges Git Quiz Git Syllabus Git Study Plan

Git Clone from Bitbucket


Share

Clone a Fork from Bitbucket

Note: The Bitbucket screenshots on this page show the default branch as master.

Bitbucket now names the default branch main, so you will see main where the screenshots show master.

Now we have our own fork, but only on Bitbucket. We also want a clone on our local Git to keep working on it.

A clone is a full copy of a repository, including all logging and versions of files.

Move back to the original repository, and click the "Clone" button to get the URL to clone:

Bitbucket clone URL

Open your Git bash and clone the repository:

Example

git clone https://bitbucket.org/w3schools-test/w3schools-test.bitbucket.io.git
Cloning into 'w3schools-test.bitbucket.io'...
remote: Counting objects: 31, done.
remote: Compressing objects: 100% (31/31), done.
remote: Total 31 (delta 17), reused 0 (delta 0)
Unpacking objects: 100% (31/31), 93.78 KiB | 51.00 KiB/s, done.

Take a look in your file system, and you will see a new directory named after the cloned project:

Example

ls
w3schools-test.bitbucket.io/

Note: To specify a specific folder to clone to, add the name of the folder after the repository URL, like this: git clone https://bitbucket.org/w3schools-test/w3schools-test.bitbucket.io.git myfolder

Navigate to the new directory, and check the status:

Example

cd w3schools-test.bitbucket.io
git status
On branch main
Your branch is up to date with 'origin/main'.

nothing to commit, working tree clean

And check the log to confirm that we have the full repository data:

Example

git log
commit 81c664c727643b638fcaf9906f2f8e820981b83d (HEAD -> main, origin/main, origin/HEAD)
Author: w3schools-test <test@w3schools.com>
Date:   Thu Apr 22 14:49:00 2021 +0200

    Updated index.html. Resized image

commit 9940ed410dc334a95900e7cf024040a1b8ef3d66
Author: w3schools-test <test@w3schools.com>
Date:   Thu Apr 22 12:40:01 2021 +0000

    Updated README.md with a line about focus
    
.....

Now we have a full copy of the original repository.


Configuring Remotes

Basically, we have a full copy of a repository, whose origin we are not allowed to make changes to.

Let's see how the remotes of this Git is set up:

Example

git remote -v
origin  https://user@bitbucket.org/w3schools-test/w3schools-test.bitbucket.io.git (fetch)
origin  https://user@bitbucket.org/w3schools-test/w3schools-test.bitbucket.io.git (push)

We see that origin is set up to the original "w3schools-test" repository, we also want to add our own fork.

First, we rename the original origin remote:

Example

git remote rename origin upstream
git remote -v
upstream  https://user@bitbucket.org/w3schools-test/w3schools-test.bitbucket.io.git (fetch)
upstream  https://user@bitbucket.org/w3schools-test/w3schools-test.bitbucket.io.git (push)

Then fetch the URL of our own fork:

Bitbucket clone URL

And add that as origin:

Example

git remote add origin https://user@bitbucket.org/user/w3schools-test.bitbucket.io.git
git remote -v
origin  https://user@bitbucket.org/user/w3schools-test.bitbucket.io.git (fetch)
origin  https://user@bitbucket.org/user/w3schools-test.bitbucket.io.git (push)
upstream        https://user@bitbucket.org/w3schools-test/w3schools-test.bitbucket.io.git (fetch)
upstream        https://user@bitbucket.org/w3schools-test/w3schools-test.bitbucket.io.git (push)

Note: According to Git naming conventions, it is recommended to name your own repository origin, and the one you forked as upstream.

Now we have 2 remotes:

  • origin - our own fork, where we have read and write access
  • upstream - the original, where we have read-only access

Now we are going to make some changes to the code. In the next chapter, we will cover how we suggest those changes to the original repository.





Free account

Track your progress

XP earned 0 Day streak 0 Spaces 0 League —

New

Learn in Adventure Mode W3Schools Adventure App

Coding fundamentals as bite-sized lessons and challenges.

×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
sales@w3schools.com

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
help@w3schools.com

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookies and privacy policy.

Copyright 1999-2026 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.