Sign in Join
Wiki copytemporary

FPC git concepts: what changed

Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
11## Differences between SVN and GIT
22
33This page describes some of the GIT concepts and differences to SVN.
44
55Subversion vs Git: [YouTube video, a brief overview of how git differs from subversion.](https://m.youtube.com/watch?v=Bb0_lO8N2yU)
66
77Information on using git can be found at either:
88
99- [[FPC git]]
1010- [[SVN to GIT Cheatsheet]]
1111
1212The latter contains a section on why there are 2 pages, and how they differ.
1313
1414## Local and Remote Branches
1515
1616Remote Branches
1717reflect the branches on the server(s) at the time of the last synchronization (pull/push). They will only be updated when a synchronization takes place.\
1818Remote branches have names that contain their server: “remotes/gitlab/master”.
1919
2020Local Branches
2121reflect your current work. They hold all the changes not yet uploaded. When you push, they will be added to the branch on the server, and the remote branch will be updated to reflect that.\
2222The local branches would just be called “master”.
2323
2424Local Branches can either be:
2525
2626- "tracking" a remote branch. They represent your work on the published branch, and your work will be pushed into the remote branch.
2727- "non tracking", without a remote branch. Either for private work, or to create a new remote branch, or to later assign an existing remote branch.
2828
2929### Naming of your local branches - Potential pitfalls
3030
3131It is good practice to keep the names of local branches equal to the name of their remote branch. However, **this is not enforced**.
3232
3333Local branches can be created with any name you choose. It is possible to create a local branch "master" to track "remote/fixes_3_2".
3434
3535This can happen by accident. Local branches can also be renamed or “moved”. The branch name is a marker for the content of a given branch. And this marker can be set from one branch to another branch. For example "git reset" can be used to move a branch like that.
3636
3737If in doubt use “git status” or “git branch --all --contain HEAD” to check your current local branch, and the remote branch to which it belongs.
3838
3939> **Note:** A branch is a marker/pointer to a commit.\
4040> From that commit you can then walk backwards using each commits links to its parent(s).\
4141> Branches do not need to have diverged from each other. One branch can simply be at an earlier commit of another branch. (Local Branches often build this way on their remote branches)
4242
4343## The INDEX (and what it means for “git add”)
4444
4545The “index” is a pre-commit area, in which changes for the next commit can be collected. Using the index is optional. Users coming from SVN may prefer not to do so.
4646
4747svn add
4848adds a new file by its name to the repository. When the file is committed, the file will be added as it is at the time of the commit.
4949
5050git add
5151adds a new or existing file to the “index”. That is, it adds the current state (content) to the “index”. A later commit (depending on the command line arguments to "git commit") will add the content as it was at the time of "git add". **Any changes made between "git add" and "git commit" may not get committed**.
5252
5353git add -N
5454can be used to just add the filename as in SVN.
5555
5656## Conflict resolution when pushing to server
5757
5858SVN
5959allows you to “svn commit” (send changes to server), even if you did not “svn update” to the latest commit.\
6060If the svn server has commits that you do not have, but none of that commit affects the files, that you are sending, then the server accepts your data, and moves your commit behind the existing other commits.\
6161This could mean, that you missed changes affecting your commit, and that the overall result is broken (not compile-able).
6262
6363Git
6464expects you do first get all existing commits, and move your commit (see rebase or merge) to the end. Of course git can not force you to check that your commit is still good and compiles (hopefully you do anyway).
6565
6666Mimicking the svn workflow. You can
6767
68-`   git pull --rebase`\
69-`   git commit -m "message" file1 file2 …`\
70-`   git push`
68+```text
69+ git pull --rebase
70+ git commit -m "message" file1 file2 …
71+ git push
72+```
7173
7274In most cases, when you have local uncommitted changes, "git pull" will be able to put them on top of the newly pulled changes from the server. Doing commit directly followed by a push means you are likely to be still up-to-date when you push. In case there was an update between your pull and your push, repeat the "git pull --rebase" and "git push".
7375
7476If there are conflicts between your changes and those from the server, like in SVN you must resolve them. See the [[FPC git]] page.
7577
7678---
7779*From the Free Pascal wiki, page "FPC git concepts", as it stood on 2022-01-18 after a change by Alextp, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*
7880Category: Version Control

Back to history