Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| linux:git [2025/06/02 21:23] – external edit 127.0.0.1 | linux:git [2026/10/23 11:08] (current) – [claude] Update git page: drop Atom, GitHub token auth, main branch, git switch, # comments, heading levels claude | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Git Basics ====== | ====== Git Basics ====== | ||
| - | |||
| - | Git is a complicated tool to use, if you don't use it on a very regular basis. | ||
| - | |||
| - | I prefer using Graphic interfaces that help a lot with git management like in Atom, but here is a recap of basic commands so I remember them when I need. | ||
| [[https:// | [[https:// | ||
| - | ==== Stage / Commit / Push ==== | + | ===== Stage / Commit / Push ===== |
| < | < | ||
| Line 15: | Line 11: | ||
| </ | </ | ||
| - | ==== Branches ==== | + | ===== Branches |
| Switch branch (option create) | Switch branch (option create) | ||
| < | < | ||
| - | git checkout | + | git switch |
| - | git checkout | + | git switch |
| </ | </ | ||
| - | ==== Atom, Git and Rust ==== | + | ('' |
| + | |||
| + | ===== Git and Rust ===== | ||
| When you create a new Rust project using Cargo it automatically initializes a local git repository. | When you create a new Rust project using Cargo it automatically initializes a local git repository. | ||
| Line 31: | Line 29: | ||
| < | < | ||
| cd existing_folder | cd existing_folder | ||
| - | git init //Skip if in a Rust project created with cargo, git is already initialized | + | git init # Skip if in a Rust project created with cargo, git is already initialized |
| git remote add origin < | git remote add origin < | ||
| - | git add . //required | + | git add . # required |
| - | git commit -m " | + | git commit -m " |
| - | git push -u origin | + | git push -u origin |
| </ | </ | ||
| - | You will be prompted for username and password of owner of the Git distant | + | Git will ask you to authenticate as the owner of the remote |
| - | Atom has a built-in | + | Most modern editors (VS Code, Zed...) detect the git repository |
| If you want to set all of your branches to automatically use this remote repo when you use git pull, add --set-upstream to the push: | If you want to set all of your branches to automatically use this remote repo when you use git pull, add --set-upstream to the push: | ||
| < | < | ||
| - | git push --all --set-upstream origin | + | git push --all --set-upstream origin |
| </ | </ | ||
| - | ==== Branching ==== | + | ===== Branching ===== |
| - | //The following is still under test and uncertain, but seems to have worked already. The commands are probably not optimized (i.e. git pull calls git fetch already so it may not be required, but this needs additional testing to clear out// | + | |
| - | + | To get a branch | |
| - | When creating another | + | |
| < | < | ||
| git fetch origin | git fetch origin | ||
| + | git switch < | ||
| </ | </ | ||
| - | This will fetch all the data in the origin' | + | '' |
| - | + | ||
| - | Then run : | + | |
| - | + | ||
| - | < | + | |
| - | git pull origin < | + | |
| - | </ | + | |
| - | + | ||
| - | This should update the local repository to the current tip of the head from the branch you are pointing to. | + | |
| - | + | ||
| - | If this does not work, maybe it is required to create the branch | + | |
| - | + | ||
| - | + | ||
| - | ===== Ressources | + | ===== Resources |
| [[https:// | [[https:// | ||