Home Git & Github
Post
Cancel

Git & Github

Git

Git is Version Control System(VCS)
So files in project on VCS can be tracked like addition, eddition and removal

through VCS,

It is possible to back up files, manage version control, and collaborate among team members

How Git store data

Most version control systems, like CVS, Supervision, and Perforce, store data as changes to a base version of each file, managing changes in a delta-based approach. In contrast, Git approaches data storage differently. Instead of tracking changes, Git treats its data as a series of snapshots of the entire project. Every time you commit, Git takes a snapshot of the current state of all files and stores a reference to that snapshot. If a file hasn’t changed, Git simply saves a link to the previously stored version rather than storing the file again. This snapshot-based model sets Git apart from most other VCSs, making it more like a mini-filesystem with powerful tools, rather than a traditional version control system.

Store data as snapshots of the project over time This is an important distinction between Git and nearly all other VCSs. It makes Git reconsider almost every aspect of version control that most other systems copied from the previous generation. This makes Git more like a mini filesystem with some incredibly powerful tools built on top of it, rather than simply a VCS. We’ll explore some of the benefits you gain by thinking of your data this way when we cover Git branching in Git Branching.

https://git-scm.com/book/en/v2/images/deltas.png Save changes to each file over time

https://git-scm.com/book/en/v2/images/snapshots.png Save changes to your project as snapshots over time

When it happends conflict

1
2
3
git fetch --all
git reset --hard orgin/main
git pull origin main

git fetch --all: Get a pre-crash file from a remote repository
git reset --hard origin/main: Reset Updated local file to pre-conflict
git pull origin main: Do a git pull as usual

Configure Git to handle line endings

1
git config --global core.autocrlf true

When saving a text file, invisible characters are typed at the end of each line to mark the end of the line.
These characters are represented differently on different Operating Systems, which can cause conflicts when committing remotely from a local repository.
To work around this, you can set up Git to automatically convert end-of-line characters to Unix style when committing

1
Git reset [file name]

It is a command to remove added file

ref: https://docs.github.com/en/get-started/getting-started-with-git/configuring-git-to-handle-line-endings

This post is licensed under CC BY 4.0 by the author.