You should see a list of branches something like this: $ git branch main test-1 * test-2 The branch with the asterisk * is the active branch. Use the git branch command in your terminal.It will probably look something like this: $ git fetch & git checkout test-2 From * test-2 -> origin/test-2 Branch test-2 set up to track remote branch test-2 from origin. Copy the git fetch command in the check out your branch dialog.Click Create branch, name the branch test-2, and click Create.Go to your tutorial repository in Bitbucket and click Branches.This example will give you some of the basics of creating and working with branches others create. When you're working in a team you'll likely have to pull or fetch branches which other team members create and push to Bitbucket. It should look something like this:Ĭreate, fetch, and checkout a remote branch You should now see both the main and the test-1 branches. Open your tutorial repository and click Branches.Total 3 (delta 2), reused 0 (delta 0) remote: remote: Create pull request for test-1: remote: remote: To * test-1 -> test-1 This tells the system that the origin repository is the destination of this new branch. $ git push origin test-1 Counting objects: 3, done. Push the branch and change using the git push branch command.To push the current branch and set the remote as upstream, use git push -set-upstream origin test-1 You will see an error because the first time you push a new branch you created locally you have to designate that branch. git push fatal: The current branch test-1 has no upstream branch. Push that change to Bitbucket using the git push command.git commit editme.html -m'added a new quote' added a new quote 1 file changed, 3 insertions(+), 3 deletions(-) Note: now the changes is part of the Git history as a single "commit" We learned about this in Saving changes. Commit the change with a descriptive commit message.git add editme.html Note: your change isn't committed to the Git history yet it's in a "waiting" state. You can use something like the following:
Make an update to the editme.html file by adding a quote.List the branches you have locally using the git branch command.$ git checkout test-1 Switched to branch 'test-1' Check out the branch you just created using the git checkout command.Create a branch using the git branch command.You're going to add a quote on your website in this branch. $ cd / Which clones the repository using the git clone command and creates the directory the clone created .Ĭreate a branch and change something using the branching workflow It might look something like this: $ git clone Cloning into ''. Clone the forked repository into the directory you just created.You might choose something like this: $ mkdir test-repositories $ cd test-repositories/ $ test-repositories The preceding example creates the test-repositories directory using the mkdir (make directory) command and switches to that directory using the cd (change directory) command. Create a directory for the repository which will be easy to navigate to.Modify the Name so it is unique to your team, then click Fork repository.Click + > Fork this repository on the left side of the screen.If you fork a repository, you get that repository and all of its branches. If the original repository is deleted, the fork remains. So, unlike a branch, a fork is independent from the original repository. The term fork (in programming) derives from a Unix system call that creates a copy of an existing process. Fork is another way of saving a clone or copy.