D
D
Dmitry2019-10-15 22:16:49
git
Dmitry, 2019-10-15 22:16:49

Am I working with Git on the project correctly?

For example, I create a project, then start a commit, git push -u origin master.
Then I create a new branch and work on it => git checkout -b new-branch
When I'm done working on the new branch, I commit the changes and push them to master => git push origin new-branch
After that, I go to github and merge this branch to master (I think this is the most wrong moment)
Then in the project I go to the master branch and do a git pull.
And so with each branch.
Please tell me how true this approach of working with the git is.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Derepko, 2019-10-15
@Odinokun

Master is the main branch of your project.
Feature / Fix / Other branch - branches that branched off from the master and in which all their essence is concentrated.
---
Finished a feature / fix, a higher priority task fell out, changed your mind or got stuck at one moment and want to do something further - commit all the changes, switch to the master, create a new branch and go again: create a branch, changes, commit, Further.
---
The guys in the answers correctly write: it is not necessary to do git push. If you don't understand why, read the purpose of this command.
---
Branches create as you want, but decide on their order.
Working with JIRA, YouTrack and other Issue Trackers, you can create branches by the issue number in these trackers and understand what was done in a particular branch.
---
It's better to merge using Pull/Merge Request, others will see changes on a particular task, someone will be able to review or start a dialogue.
You can also make several branches, make PR / MR for them and merge them all together at the right time (for example, when some branches are waiting for changes from other branches, so they cannot be merged yet)

E
Evgeny Samsonov, 2019-10-15
@bitniks

Correct, but merging a branch into master is optional on github. This can be done locally, and then push the master to github

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question