💾 Archived View for gemini.ctrl-c.club › ~vitorg › t › git-tutorial.gmi captured on 2021-12-17 at 13:26:06. Gemini links have been rewritten to link to archived content
-=-=-=-=-=-=-
So, you probably tried to use git and stopped across 103723432974982642 sites talking about it. Yet i'm one more.
Probably you have it pre-installed. If it's not, use your package manager to install it.
sudo apt install git # debian variants
sudo pacman -S git # arch linux variants
sudo emerge -qa git # gentoo (you probably know how to use git, come on...)
sudo pkg_add git # netbsd
doas pkg_add git # openbsd
sudo pkg install git # freebsd
You can use homebrew: brew install git
git init # initializes a repo
git add # adds a file to be tracked by git
git commit # commit changes on the added files
git push # sends to a remote repository
git pull # pulls from a remote repository
git clone # clones a remote repository to the local machine
If you have a cool project (it doesn't even need to be a project; any files you want to have a better tracking), you can use git to manage the changes and versions of your files by using git init into it's folder.
Yeah, you created what we call a git repository, but it doesn't have any content yet. To add content to your repository, you need to commit. You can do this by selecting the files you want in the directory using git add [filename]. If you want to add all files, you can do git add . so it tracks everything. Then, you need to commit it with git commit -m [message], so that it stores the changes in the .git directory.
Now, you have some commits and changed/added/deleted files, but you want to have it somewhere else? Or even, you want to open your project to the world? It's pretty simple, all you need is a account on a git hosting service (my go-to today is codeberg, planning to change to tildegit tho) and a git repository. Then you can add a remote with the command git remote add [name of remote, generally origin] [link]. An practical example: git remote add origin git@codeberg.org:myusername/myrepository
But then, you have another computer that needs to have the same repository, what do you do? Simple just git clone [repository url]. This copies all the repository commits and files to your local computer, allowing you to go back/forward in the commit history. What if it had an update on the remote repository? You can simply use git pull to update your local repository.
~2021-12-15 @ 15:34:40 UTC -3