mandychew/Git-Tips

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 

Repository files navigation

Useful tips for collaborating on the same repository.

1. Avoid multiple people editing the same file
2. Clone repository to Desktop and edit files through local repository
References

When editing different files, there won't be any conflict when committing the file.

Please avoid editing files directly on the website, especially when multiple people have to edit the same file. Instead, I recommend to clone the repository to Desktop, and edit files through your local repository.

It's because when multiple people edit the same file concurrently on the website, only the person who made the last commit will be saved. The other commits made by others will not be reflected on .

  • For example, Alice and Bob are editing the same file (in the same repository) on the website.
    Alice commits her version first. When Bob commits his version, Alice's changes are not saved anymore, it only shows Bob's changes.
  • If this mistake was made, the unsaved commits made by Alice can be accessed in the file's history on /VS Code.

On the other hand, editing files on the cloned repository won't lose any person's changes.
Using the example of Alice and Bob again...

  • Alice commits and push changes to origin ( website) first.
    When Bob commits and push changes to origin, Desktop will warn him that the file has been changed by Alice. Desktop won't allow Bob's commit to be pushed to origin until he fixes the conflict.
    Only after fixing the conflicts, can he commit the resulting file (with both Alice's and Bob's changes).
  • To reduce the number of conflicts to fix when committing, it's recommended to do pull requests regularly (and before starting to edit a file).

For more details on editing files on Desktop (cloned repository), this answer explains it well.

To understand why there's a difference between editing on website and a cloned repository, check out this website.

Tip 2:
https://www.quora.com/Should-two-people-work-on-the-same-file-at-the-same-time-on-Git
https://stackoverflow.com/a/4028856/15951751

About

Useful tips for collaborating on the same repository

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published