How to work with two different BitBucket accounts in SourceTree - bitbucket

I have two different bitbucket accounts set up. One is for work projects and one is for personal use. In BitBucket I have set up a repository in each of the accounts for different projects.
In SourceTree I have a few existing personal projects that are syncing up to my personal repository on SourceTree. In the left hand panel I can see my "Develop" branch for one of those personal projects and on the remote in BitBucket I can see the remote repo.
In SourceTree I don't see an obvious way to keep my two accounts separate. For example, I have added the work repo in SourceTree but when I try to commit an initial version of a work project it only gives me the option to commit my personal project branch.
How can I now add my work repo locally and sync only those work projects into repos on that work BitBucket account?

For SourceTree 2.0.2+ on Mac only with GitHub accounts:
Click from menu File-> New/Clone
In the dialog click settings icon.
In the resulting popup menu click Settings
It brings a dialog with listing user accounts. Add your additional account to the list.
Close the dialog.
Click remote button (next to local) on the tool in image shown below.
All your added accounts will be listed and their respective repositories with button to clone.
Hope this helps.

NOW on Windows, you do it in the Clone/Add/Create Repository dialog:
Click the "Hosted Repositories" button (internet icon)
Click "Edit Accounts"
Click "Add"

Well I have done this way:
Click on Settings
Click on Advance tab
Enter your Full name and Email address (Email should be match with your Bitbucket account)
Click on OK
Click on Close (To close current window)
Restart again
Note: You must have added account in Source tree. (Open Source tree -> Click on Setting icon < Right Top corner> -> Click Settings -> Add your Account -> Set as Default account)
Hope this would help you.

In Windows, you can do it by following steps:
Click on settings button ( right top corner). It will open dialog box.
Click on Advanced tab.
Uncheck the "Use global user settings".
Now you can enter username and email id for corresponding repository.
Click on OK to save changes.

If I understand your question correctly, you still need to do a little bit more set of your bitBucket accounts.
You can also test the BitBucket server to see which account you are logging in with.
ssh -v git#bitbucket.org
This link help me, follow these instructions here and you should be successful.
The key part you need is in you .git/config.
You'll need separate entries for each.
Use different SSH keys for different accounts on the same Git hosting

In Windows you may have more than one account (you can have even GitHub and BitBucket side by side). For example, assuming the account you have now in SourceTree is with BitBucket and you want to add your GitHub account to it as well, do the following:
From menu, choose File->New/Clone
In the Source Path/URL put the repository url for a repository you have on github
Wait for a few seconds and it asks you for username/password. (first, buttons might be disabled for example for entering your password. So wait for a few seconds first)
Add the new username and passowrd on github.
Now if you like you can cancel the clone.

For BitBucket account/repos, you can include the username you want to use as part of the git URL. SourceTree will then ask for the password for that username.
https://username#bitbucket.org/account/repo

If you've already cloned a repository with ssh on the Mac version, and you want to change the account for it, you can do this by changing the host name of the remote.
If you've let SourceTree modify your ˜/.ssh/config , then it will have added some entries starting with:
# --- Sourcetree Generated ---
Host <account name>-<service name>
...
Choose the <account name>-<service name> combination that you want to use and modify the path of your repository (in Remote Settings). Your new path will be something like the following format:
git#<account name>-<service name>:<account name>/<repository name>.git
(Actually, you can use this solution for working copies not cloned by SourceTree too.)

on windows the tool has a bug
no matter what I've tried from within the tool it was always using a previews git account which was cached somewhere...
so I searched all files where sourcetree was installed and I found a file C:\Users\WIDNOWS_USER\AppData\Local\Atlassian\SourceTree\userhosts
there I had cached the old git user/account name and it was driving me nuts in the app.
I updated this file, deleted the old account name and added the new one, restarted the tool and it started to work fine.
there's also a file
C:\Users\WIDNOWS_USER\AppData\Local\Atlassian\SourceTree\passwd
check that one too and if your cached account with passwd is there too clean it out, do not add here anything, the app will do it first time when you enter your password for the new acccount

Related

Block direct pushes to branch

My team uses both gerrit and gitlab and this sometimes causes issues when people are working on both gerrit and gitlab at same time.
While working on gerrit instead of
git push origin HEAD:refs/for/master we wrongly issue git push.
So instead of creating a changeset, the code gets automatically pushed to Remote branch.
How can we block all direct pushes to a branch in gerrit?
Go to:
Gerrit > All-Projects project > Access
Look at the "Push" permission at the "refs/heads/*" category. Probably your team has an "ALLOW" in this permission. Edit the project permissions to remove it or to add a "BLOCK" specific for your team.
there is an access category - push
so this can be disabled for a group under the project admin site. more info can be found here

Veracode as a precommit hook for git

How to integrate Veracode scanner as a pre-commit hook for git working repository? How can we check weather the scanner is actually running?
You can create a GitHub Action about Veracode static scan analysis. To do this you can follow the steps below:
In the Security tab of your GitHub project (you need to have admin rights for the GitHub project), click on "Enable settings" for "Code
scanning alerts".
This takes you to the Settings of the project, where you need to “Enable” “GitHub Advanced Security” for “Code scanning”,
and then click the “Go to code scanning” button that will be enabled.
Scrolling down on the list appearing with multiple code scanning tools, you pick “Veracode Static Analysis” (usually appearing on the bottom of the page).
Clicking to “Set up this workflow”, automatically creates a subdirectory in master branch in .github/workflows path. The workflow is configured in a .yml file, that contains the steps of the pipeline.
Prerequisite: you need to set up Veracode API Keys as Project Secrets (have a look here Create Veracode API keys and here
setup GitHub Action Secrets for Repository. Name your API Keys as VERACODE_API_ID and VERACODE_API_KEY (as these are the names that are set in .yml file or change them accordingly in both locations)
In the .yml file that got created automatically there is a pipeline that runs according to the rules set on the line where it says
you can have a look at this link for more information on push/pull request branches/tags
branch names can be altered, following regular expressions as well, see here for more info.
You can configure the Action to run on schedule as well.
Hover over “cron” to see the man-read format that appears. With this, the Action will run according to cron. Scheduled workflows run on the latest commit on the default or base branch.
Find more information on how to configure scheduled events on GitHub Actions here
In the Actions tab of your Project you can now see the logs of the run of the pipeline and each run's status.
After you have set up the GitHub Action as described above (steps 1-8), and the Action has run well (check its status as described in step 9) in the Security tab of your GitHub project, you should be able to see that "Code scanning alerts" are "Active", click on "View alerts", that takes you to the list of the Veracode flaws if any.

Login in screen pops up in sourcetree

My desktop was previously used by the previous employee at my office. In source tree I have my account logged in but my at random times the previous users login screen pops up with username field disabled
and it comes two times,when I click cancel the second screen pops up. I am fed up with this problem. I have done with everything to try and solve this problem but it will just not go.
Quite often this occurs because either a repo has multiple remotes, or a repo has a remote that you've not got permissions to anymore is still bookmarked (even if the tab isn't open in SourceTree).
For example I had 3 repos from a previous contract that I no longer had access too, whilst I didn't have the repos open in tabs within SourceTree, the repo was bookmarked so SourceTree kept trying to authenticate it; removing the bookmarks and then restarting SourceTree fixed the problem.
Removing old/non accessible repositories
In the latest version of Source Tree (2.1.2.5 at the time of writing), Select the New Tab + button, under Local repositories -> All Repos ensure that all the Repos are ones you have access to (might have to check each one can do a fetch)
Delete any bookmarks you do not need/have access to
Restart Source Tree
Removing old/duplicate/excessive remotes
Select your repository tab
Go to the Repository menu and select Repository settings (Ctrl+Shift+,)
Under the "Remotes" table, ensure the remotes are correct (most likely just origin pointing to bitbucket)
Good luck.

Leave a repository on bitbucket

Last year, I was working with some other people on a computer science project. So, I created a bitbucket repository and invited everybody. As we know each other very well, everybody is an administrator of the repository and I'm the owner.
Today, I would like to clean up my bitbucket repository list. But, I can't find how to leave a repository. When I go in the settings menu, the only thing that I can do is "deleting a repository". It's not what I want to do because I want to leave the repository for the other people.
For some repository (when I'm not the owner), I can revoke myself, but for the other, I can't. Do you know how can I do that? I would like to find a solution without needing to make a ownership transfer as it involves making a transfer request and then, waiting some time to get the answer.
Thank you
Go to 'Your profile and Settings' left bottom corner & Tap 'All work spaces'
Tap 'Leave'
I would like to find a solution without needing to make a ownership transfer as it involves making a transfer request and then, waiting some time to get the answer.
Somebody must own the repository, and you can't leave a repository that you own.
You could create a team and transfer the repository there, then invite the other users to the team. Transferring your repo to a team you create should be instantaneous.
Or you can transfer the repository to an existing user and wait for them to respond, as you have suggested.
Workaround:
Disable "New source browser experience" in here: https://bitbucket.org/account/user//features/
Then click "revoke" in here: https://bitbucket.org///overview

Adding source control to my project in xcode

I am following this tutorial in raywenderlich.com: http://www.raywenderlich.com/22590/beginning-automated-testing-with-xcode-part-12. I have problem linking my project to my repo. I have already created the repo in my github account and downloaded the starter project.
I face two problems:
1) xcode keeps asking for my password and when i enter my github account password and username, it keeps saying my authenication is wrong. its username says git always...
2) In the tutorial, to get an initial commit it says: Go to File\Source Control\Commit (⌥⌘-C) and on the following screen, enter a commit message like “initial commit” and click Commit. but when i type initial commit, the commit is not highlighted and doesn't allow me to click it.
Need some guidance to start on source control for my iOS projects..
Honestly? Don't use Xcode for that. I know I am not answering your question, but there are better ways of doing it. At the moment I am using Command Line and it's more than enough for what I do. Sometimes I use SourceTree, but most of the times it's Command Line.
1) I think you clone your project from the github.com with the https link. You should choose the git one, something like this: git#github.com:username/projectname.git. Or you should refer to GitHub's help page at https://help.github.com/articles/set-up-git#platform-mac , which tell you to install the osxkeychain credential helper.
It is written on GitHub:
The credential helper only works when you clone an HTTPS repo URL. If you use the SSH repo URL instead, SSH keys are used for authentication. This guide offers help generating and using an SSH key pair.
2) Have not got any good idea right now.

Resources