0

I created a repository with two developers. First developer created a new branch mysql_login and pushed a file. Other developer created a new branch mysql_register and pushed a file.

Now my questions:

  1. Is it possible to pull another branch so that git branch command displays:

    master

    mysql_login

    mysql_register

My second developer was on branch mysql_register and executed the command:

git pull origin mysql_login

This command pulled files from branch mysql_login and merged into mysql_register

  1. Is it possible to prevent second developer from pulling or pushing to branch mysql_login?

Like I can prevent users to access/pull/fetch other branches.

I hope I am clear with my questions

Thanks

isherwood
  • 46,000
  • 15
  • 100
  • 132
Ashutosh
  • 3,511
  • 7
  • 41
  • 82
  • Re 1, try `git fetch`, then `git branch -a`. The `-a` flag makes sure remote branches are included in the list. Re 2, this really depends on how your repo is hosted on the server, but you should try using `git fetch` instead of `git pull` if this is still confusing to you. – Sven Marnach Oct 11 '16 at 14:58

1 Answers1

2

Is it possible to pull another branch (...):

Use fetch and checkout commands to that. git fetch will update repository status from remote and git checkout <branchname> will create a local copy of remote branch resulting in branch list you need

Is it possible to prevent second developer from pulling or pushing to branch mysql_login?

You can set branch restrictions with bitbucket, but I believe your problem can be solved with correct git usage - have non-shared user feature branches and have one developer merge progress into common codebase in master (or development) branch.

Your second developer should also do fetch and checkout another branch to prevent unwanted branch merges.

See for example a simple git branching model.

Finwe
  • 4,943
  • 2
  • 26
  • 38