Sourcetree isn't populating my dev branch in pull - atlassian-sourcetree

Ever since I had to recreate my dev branch due to some mishaps with Git, Sourcetree doesn't prepopulate the "dev" branch in the pull and push dialogs. Every other branch works fine, but not dev. It's not a big deal, but I have to select dev manually every time. What gives?
Screenshot:

The "Remote branch to pull" dialog is pre-populated based on the remote branch that is being "tracked" by your local branch. (When you check out or push to a remote branch, SourceTree usually sets this up automatically.)
If your dev branch is not tracking a remote branch, then the dialog will load with no selection. To change this, right-click the branch and select 'Track remote branch."

Related

Hide master branch in GitHub Desktop

Our implementation of GitHub is very basic.
We have one master branch (default) and then one open branch (DEV) for new developments.
Ideally we won't have more than one branch open at the same time.
Master branch is a protected branch so only admin can do changes on there.
The idea is to use GitHub Desktop to manage the developments locally in a computer as it would be too complex to manage it via the WebUI due to the kind of files being used.
Also we have the challenge that team is mostly consultant/external and rotating, so not everyone is familiar with the GitHub funcitonality...
Due to this, I would like to know if it is possible to avoid checking out the master branch when cloning our repository.
I am mainly aiming for this approach as I have problems when someone clones the repository locally and starts developing into the local master branch (without switching to the DEV branch first) and getting the error when pushing to server (due to the protected branch).
At that point the developer has already developed a lot and now is time for him to switch all his development to the proper branch instead of using the master one...
Is there any way to achieve that initial checkout from master to be avoided?
EDIT:
just immediately after posting I thought on changing the default branch to DEV so when someone clones it will always be directly targeted to the DEV branch instead of master...
Would this have any bad consequence for such a simple implementation?
Note that branch is created by admin as well as deleting it after pull request has been merged...
So this could be his responsibility to change the default branch every time a new development needs to be done and move it back to the master when development is finished...
Does it have sense?
When you clone a repository, whatever is "checked out" on the remote end becomes the default branch that is checked out on the local end.
For remote bare repositories, which is usually the norm, you have a "default branch" configuration that is used. In your case this is set to master.
You can change this on github to be DEV instead, so that fresh clones of the repository checks out DEV by default instead of master.
You do this by navigating to your repository on github, and click on the "X branches" button that is just to the right of the button/dropdown that shows the default branch selection on your repository page:
on the page that shows branches, click on the "Change default branch" button to the right of your current default branch:
and then finally select your new default branch and click Update:

Github Protected Branches with GitFlow

I've got a repository with my develop branch protected and I'm using the GitFlow branching model. There's two branches; develop (containing features currently being developed) and master (latest deployed production code).
My develop branch prevents commits being directly made via GitHub's Protected branches. When you locally finish a hotfix using GitFlow, it automatically merges the hotfix branch into your local master and develop branches. However, pushing changes directly on the develop branch are not permitted as this is a protected branch
How can you overcome this? At the minute everytime I am creating a hotfix I have to:
Manually turn off the branch protection
Push the develop branch
Turn it back on
This is not automated and therefore, not really acceptable.
Are you the owner of the GitHub project and do you have the administrator role setup with your account (or can you grant administrator access to your account)?
In this case I would recommend you not to protect the branch for administrators. This way you can guarantee that other persons are not pushing directly to develop, but all "knowledged devs" with administrator access are able to. They should be aware of what they are doing, though.
You can edit this behaviour under https://github.com/${name}/${repo}/settings/branches/. My settings do look like this (the last checkbox is important):
Note: maybe you could also use the "Restrict who can push to this branch" option.
Enable 'Require pull-requests' on GitHub.
After you merge the hotfix in your local master you can create a hotfix branch from it, to create a pull-request in origin. Your master will be different, but you can reset and stash and pull in the origin/master.
git checkout -b hotfix
git push origin hotfix
# merge
git checkout master
git reset origin/master
git stash
git pull --rebase

How to push unsynced commits to GitHub?

I have a GitHub source control tool added to my copy of Visual Studio 2013 and when I right click on the solution and make a commit it says created the commit locally. When I try to sync the commit with the server, the sync button is greyed out.
My question is how do I set it up or what steps do I take so that the commit is pushed to the server?
It looks like you do not have the upstream remote / branch configured for this branch. Visual Studio operates as if the "push.default" configuration is set to "upstream".
If you go to the branches page, this branch should be listed under the "Unpublished" branches section. From that page, you can choose to "publish" this branch by right clicking on the unpublished branch and selecting publish in the resulting context menu. This will push the branch to the origin remote (with a branch of the same name as your local branch) and set the upstream tracking information for this branch. From then on, you can push and fetch from the Unsynced Commits page.
Here is a screen capture of where you need to go to publish an unpublished branch:
You need to add the online GitHub repo as a remote in your local git repo.
On the command line, that's git remote add origin <urL>; I don't know if the VS git UI exposes this.
We use Atlassian Stash but also found the Visual Studio UI a bit confusing at first. The sequence that works for us, using only the UI, is as follows:
First you have to add your "username" and e-mail address in the Git global settings via Team Explorer > Home > Git > Git Settings
On the "Solution Explorer" tab, right click on the solution and "Add Solution to Source Control" and choose Git.
On the "Team Explorer" tab, click on the repo you just created and go to branches
Choose the master branch, right click on it and choose "Publish" - you will be asked for the remote URL whereupon after you enter it, you will get a username/password prompt (for the remote server i.e. GitHub, Stash, etc.)
All this is doing is git push origin masterbut Microsoft chose to make it confusing by giving it another name.
Wait for the "publish" to be completed (there will be a file transfer status shown in the UI)
Once it is completed, go to the commits tab and you will see that all the options for Push/Pull/Fetch etc are available
Note: If you create another branch locally, you will have to push, er "publish", that one as well before the remote knows about it.
Final note: Visual Studio will not create projects and repos for you on the remote. You have to make sure the repo is setup on the remote before you can push a branch to it.
Weird issue: We found that if you try to push to a branch but fail (due to incorrect URL or a permissions issue) that we had to go back to the command prompt to "fix" the remote configuration for the repo/branch. This is using the standard git command:
git remote add origin https://myuser#stash.mycompany.com/scm/myproject/myrepo.git
After you publish a branch as in #jamill's answer you may run into this.
In Team Explorer, I was able to publish a branch, but then I could not do anything. Pull and Push were grayed out as shown:
So I did Actions > Open Command Prompt. Then Type:
git push origin My_Branch_Name
After doing this I could see the branch and my commit in my remote. (Github or whatever in your case). Also when running the command, the output said,
remote: Create pull request for My_Branch_Name:
If you want to keep this branch and merge it into master, then you can create a pull request on your remote. Otherwise as in my case I want to abandon the branch. You don't have to do anything.

Git branching messed up

I'm using Egit on Eclipse Mac and PC to sync a project that has three branches:
master
dev
rendersystem
I've created the project on the Mac and when I created the two branches dev and rendersystem I've used revs/heads/master as the Source ref and as Pull strategy I've used Merge.
Now I've switched to my PC and imported the project with Egit incl. all three branches. But if I change to dev or rendersystem branch it tells me that these branches are remotely tracked (in Branches dialog, Remote Tracking /origin/dev and /orginin/rendersystem).
If I check out dev or rendersystem branch and change my code, then commit it and try to push it to Github, it doesn't push the dev or rendersystem branches, only the master it pushed.
My question is now: How do I change the dev and rendersystem branches so that they are in a state where I can push them to Github from my Mac and PC?
Sorry if this question sounds confusing, but Git is one hell of confusing for beginners.
Remote tracking branches are read-only in git, as they represent remote changes. A Fetch will only update these remote tracking branches. A Pull first executes a Fetch, and then merges the changes with a locally editable branch.
On the source computer there was no need to create this branch, as it was initialized locally, and pushing the branch can create the remote branch.
You can create a local branch from the remote branches by Right clicking on the Remote branch in the Git Repositories view, and selecting Create branch... After that, your branch would be writable.

Troubles merging branches with GitHub for Mac

I am trying to get the hang of merging branches with the GitHub for Mac GUI. I'm not sure if it's me or the client at this point....
I have a repo with master, staging, production branches. I created a file in master called test.txt. I then added a test line to it. I committed and synced in the master. I merged from master to staging using the gui, then hit merge. I also re-clicked "branches in sync" to re-sync them. The new line shows up in GitHub under master, but not under staging. In my local repo, it shows both in sync with that latest commit.
My plan was to edit in master, merge to staging to deploy and test, rinse, lather & repeat until it's good, then merge to production (at this point all should be in sync).
Am I doing something wrong?
That looks like GitHub for Mac issue 3:
Merging branches does not recognize new changes to sync
It seems that when merging the receiving branch does not recognize that new changes can be synced with Github
Steps performed
add and checkout "experimental" branch
add/commit to experimental branch
merge experimental branch into master
master displays button "Branch in Sync" even though it is no longer in sync - pressing button does nothing
How to fix
add a new commit directly in master
"Sync Branch" appears and can sync to Github
The OP skinnygeek1010 reports:
I've found a nice workaround:
To merge master with staging, merge with the GUI.
When it's finished, switch to staging and then go to the drop down menu: Repository > Synchronize (Cmd S).
The merge will instantly show up on GitHub (won't work if you Sync in master though)