I had a few questions while working with git
在使用Git时,我有几个问题
- How to always have the latest version of git repository
- What rules should be followed in order not to get conflicts with git push
- Do I need to do synchronization when I clone git repository. (HEAD -> main, origin/main) because it is not displayed this way during the clone, it is necessary to merge the branches.
- How to revert to a specific version on a remote server.
- I have not found a satisfactory answer to my questions on the Internet.
I made a git clone url -> coding -> git add . -> git commit -m "desc" -> git push. my friend too. But after several commits, a file conflict occurred. I solved the problem by merging the local branch with the remote repository. To avoid such problems, how to commit correctly?
我创建了一个git克隆url->coding->git add。->git Commit-m“desc”->git推送。我的朋友也是。但在多次提交后,发生了文件冲突。我通过合并本地分支和远程存储库解决了这个问题。要避免这样的问题,如何正确承诺?
更多回答
优秀答案推荐
- Try this when you want to synchronize
git fetch upstream ->
git checkout main->
git rebase upstream/main
Git上游取回->Git签出主目录->Git Rebase上游/主目录
These are great questions Dias,
这些都是很好的问题迪亚斯,
- always be sure to
git pull
prior to working in a repository, especially when working on a team. This will avoid conflicts and the need to merge.
- This goes in conjunction with your first question. If you pull before working on a repository, you will avoid most of the major conflicts.
- (please specify synchronization)
- Great Answer
Please let me know what else needs to be clarified. Thanks.
还有什么需要澄清的,请告诉我。谢谢。
To avoid such problems, how to commit correctly?
Commits have nothing to do with merge conflicts.
It's about changes in the same files your teammates and you contribute.
提交与合并冲突无关。它是关于你和你的队友贡献的相同文件的更改。
Sometimes you want to keep both changes in file, sometimes you want to leave only latest version, sometimes earlier.
This is about tracking of working lines within a project. Generally, you have to do it manually;
it is good advice to do git pull
at the beginning of every working day though.
有时,您希望将这两个更改都保留在文件中,有时,您只希望保留最新版本,有时是更早版本。这是关于跟踪项目中的工作线。一般来说,你必须手动完成;不过,在每个工作日开始时做GIT Pull是个好建议。
更多回答
我是一名优秀的程序员,十分优秀!