Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| linux:git [2019/05/28 16:01] – [Atom, Git and Rust] mh | 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 ===== | ||
| - | ==== Atom, Git and Rust ==== | + | Switch branch (option create) |
| + | < | ||
| + | git switch branch_name | ||
| + | git switch -c create_branch_name | ||
| + | </ | ||
| + | |||
| + | ('' | ||
| + | |||
| + | ===== 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 23: | Line 28: | ||
| < | < | ||
| + | cd existing_folder | ||
| + | git init # Skip if in a Rust project created with cargo, git is already initialized | ||
| git remote add origin < | git remote add origin < | ||
| - | git push --all origin | + | git add . # required |
| + | git commit | ||
| + | git push -u origin | ||
| </ | </ | ||
| + | |||
| + | Git will ask you to authenticate as the owner of the remote repository. GitHub no longer accepts account passwords for git: use a personal access token (entered as the password) or an SSH key (with an SSH remote URL). | ||
| + | |||
| + | Most modern editors (VS Code, Zed...) detect the git repository automatically when the project root folder is opened directly. | ||
| 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 |
| </ | </ | ||
| - | Atom has a built-in git feature | + | ===== Branching ===== |
| + | |||
| + | To get a branch | ||
| + | |||
| + | < | ||
| + | git fetch origin | ||
| + | git switch < | ||
| + | </ | ||
| + | |||
| + | '' | ||
| + | |||
| + | ===== Resources ===== | ||
| + | |||
| + | [[https://git-scm.com/ | ||