Can two different branches refer to the same commit?

Can two different branches refer to the same commit?

Yes, two branches can point to the same commits.

How does git work with multiple branches?

Git offers a feature referred to as a worktree, and what it does is allow you to have multiple branches running at the same time. It does this by creating a new directory for you with a copy of your git repository that is synced between the two directories where they are stored.

What is the command to create and switch to a branch?

New Branches The git branch command can be used to create a new branch. When you want to start a new feature, you create a new branch off main using git branch new_branch . Once created you can then use git checkout new_branch to switch to that branch.

When do you need to use multiple repos for a project?

When you have multiple projects across multiple repos, “Am I using the right version of this code?” is a question you always have to be asking yourself – if you’ve made a change in one repository, is it picked up in a dependent one? If someone else has made changes in two repositories have you updated both of them? etc.

Why do you need a single repository for all your code?

For me the single biggest advantages of this sort of organisation style are: It is impossible for your code to get out of sync with itself. Any change can be considered and reviewed as a single atomic unit. Refactoring to modularity becomes cheap.

Can you push from one branch to another in Git?

Yes, you can push any local branch to any remote branch. The syntax is If your current branch (the one you want to push) is called develop, the command would be The answer by Roman is correct. However, there is an additional step that might not be obvious for some.

Which is better a monorepo or multiple repositories?

This is by far the biggest advantage of a monorepo for me, and is the one that I think is the most counter-intuitive to people. People mostly seem to want multiple repositories for modularity, but multiple repositories actually significantly hurt modularity compared to a monorepo.