How to use branch in git

Asked 1 years ago, Updated 1 years ago, 49 views

Is it possible to do something like the attached file with the branch of git?

Current operational pattern is
like 1 If I push it, it will be reflected on the public site.
If there is a bug when making a big change, it will be published as it is.

Is it possible to make a branch into a public repository and check it out?
(Pattern 2)

Also, merging from branches and pushing the master is
I think it's common, but if a bug appears after pushing
Is it possible to push it again from the master before the local merge to the state before the bug occurred?
(Pattern 3)

There was a big change this time, so I worked a lot locally
(I did add a few times locally in the middle)
I had to push it to the remote location all at once, so I thought about this.
"If there is a more efficient way to recommend it, I would love to visit there."
Thank you for your cooperation.

Enter a description of the image here

git

2022-09-30 21:22

2 Answers

First of all, I'm curious.

The bare repository is one of the features of the git repository described below that does not create a "file system at hand," so I think it's strange for the server to read the files directly here and do something about them.

Rather, this server is probably a repository server like github or gitlab.

Suppose the current operational flow was a configuration of "local" <-> "repository server" <-> "production server".The production server then appears to be running a script to periodically pull from the repository server.

Yes, it's possible.I will push my branch from my hand.On the production server, you can rewrite the script you want to pull from mybranch on the repository server to mybranch on the production server.

Git can actually push from any branch to any branch on any remote.

 git push remote-name local-branch:remote-branch

That's right, so if you use this, you can do it, but I think it's better to match the local and remote branches honestly.I think it will be troublesome.

In git, the repository consists of the Work Directory + Version Control Information.
A bare repository is a repository in a configuration that does not have a "work directory."

The production server is a machine that is actually configured to act as a server when it reads and executes the contents of the code base that is actually committed to git.The bare repository only has information files that git creates for version management, so I suspect that the production server will never read this repository and work.


2022-09-30 21:22

So, is it possible to make a branch into a public repository and check it out?

It depends on how you operate it, but you can do it.
Create a remote branch for verification.

Also, I think it's common to merge from branches and push the master, but if a bug appears after pushing
Would it be possible to push it again from the master before the local merge to the state before the bug occurred?

I don't know if it's common or not, but I think there are many projects that provide remote branches for applications such as develop and deploy.

  • Example: Each developer can push the develop branch, deploy can push the authorized member, only the leader can push the master, etc.

Also, once you delete a commit that you pushed to the remote, the history will be corrupted, and it will cause trouble if there are other people who are referring to the commit.If you want to cancel it, you should create a revert commit.


2022-09-30 21:22

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.