+ 1

How to work with Git & Github?

Hello, I'll state the way I think you should work with a repo on github. I am not sure it's correct, so I'd like y'all to help me with this. 1. In order to get the repo on your local machine you do: git clone (repo url from github) 2. You should make a new branch for your own changes by typing: git branch new_branch 3. You do your changes 4. If everything you changed is fine and didn't ruin everything - you merge the main branch with your branch by doing: git checkout main git merge new_branch 5. You upload everything to github: git push Now, how do I make sure that while I was working on my machine, someone else didn't change the repo on github? Otherwise there will be conflicts... how often and in what stage to I do "git pull"? Thanks.

15th Aug 2022, 8:41 PM
Yahel
Yahel - avatar
2 odpowiedzi
+ 4
usually, in a professional environment, every merge to main is done from a pull request on github. This allows colleague to review code before merging. when coding, it's also important to stay focused on that one feature. otherwise you might step on someone else's code and create conflict. do a git pull right before going into a new branch and it should be good most of the time.
15th Aug 2022, 9:43 PM
Apollo-Roboto
Apollo-Roboto - avatar
+ 2
Hi! and would you like to take a git training course so that you can eventually answer your own questions? https://www.sololearn.com/learn/1236/?ref=app
15th Aug 2022, 9:32 PM
Yaroslav Vernigora
Yaroslav Vernigora - avatar