Reputation: 13
I have created a repository (test_repo) under a project (test_pro) in bitbucket from my laptop. I have created 3 branches: master (default), backend, frontend.
Now I want to do all my backend-work (php code) from my laptop and want to push to backend branch. And I want to do all frontend-work (html,css) from my office desktop computer and want to push to frontend branch.
Now how can I connect to my repositary and do push and pull operation from my laptop and desktop computer using git bash.
I am new to this VCS. I am trying to learn.
Upvotes: 0
Views: 4485
Reputation: 45809
Since you mention that you're new to version control systems (and therefore presumably new to git), I think the first thing it's important to know is that it sounds like you might be using branches incorrectly.
Branches generally shouldn't represent different projects or different parts of a project. (What is "a project' is somewhat subjective; you could say that you have one project with frontend and backend parts, or that you have a frontend project and a backend project. I sometimes talk about whether two sets of code are likely to change togehter vs. independently, or whether the code all results in one deployable artifact or two, in deciding whether multiple repos should be used.)
But in any case, within a repo, what you don't want to do is have one set of files on one branch and o different set of files on another branch. Branches are meant to be versions of the same content. What problems you might have by having a "frontend' branch and a "backend' branch depend on how exactly you do it, but it usually does lead to problems.
Now, there are legitimate reasons to have many computers connected to the same remote repo. That might be multiple developers collaborating on a project, or just being able to work on your project from whatever device you happen to be using at the moment. To do that, you need to understand git clone, and you need to understand any access requirements imposed by the hosting environment for the remote repo. I think other answers have that covered for your scenario.
Upvotes: 2
Reputation: 540
first you need to create a ssh key for each computer. in linux or mac you can use the command ssh-keygen. after that you need to add each public key to your bitbucket account.
Next you need to clone the repository in each computer an checkout the corresponding branch. lets configure everything from your laptop:
git init
echo "this is the repo" >> readme.md
git add -A
git commit -m 'initial commit'
git remote add origin [email protected]:you/yourrepo.git
git push -u origin master
git checkout frontend
echo 'this is the frontend' > readme.md
git add -A
git commit -m "this it's the first commit in the frontend"
git push -u origin frontend
git checkout backend
echo 'this is the backend' > readme.md
git add -A
git commit -m "this it's the first commit in the backend"
git push -u origin backend
in your desktop pc:
git clone [email protected]:you/yourreponame.git
git checkout origin/frontend
Upvotes: 1