====== Git ====== ===== Commands ===== ==== Rename Branch ==== In my examples I'm replacing branches called 'master' with ones called 'main'. - Make sure your local and remote repos are up to date. - ''git branch -m master main'' to move all your stuff, including history, over to the new branch. - ''git push -u origin main'' to send it to the remote - Next you need to change what is set as the default. Dunno how to do this with just Git, but with [[Gitea]] (and [[Github]]) you can just do this in the web interface (settings > branches ...). - To delete the old branches you're not going to use anymore: * If you're using something like [[Gitea]] or [[Github]]: * You can delete the old branch from their UI, from the 'branches' tab. * Then use ''git fetch --prune'' to delete anything locally that's not on the remote (if that's safe in your case). * If you want to do it from the command line apparently: - ''git branch -d master'' to delete the old local branch - ''git push origin --delete master'' to delete the old remote branch - Finally, we need to reset the HEAD: ''git remote set-head origin --auto''. You can also do this in your ''.git'' directory, iirc. ===== .gitignore ===== The ''.gitignore'' file tells git which files you do not want included when you upload to your repository. For example fiels with personal info, or just things irrelevant to other people who may contribute. They can live multiple places, so you can exlude things globably, or per-project. ==== Windows ==== It's a little bit fiddly to make dot files on windows, but you can do so from the command prompt. Either: * ''NUL> .gitignore'' to create a new file. * ''REN [existing file] .gitignore'' to rename a file you've already made. To open a command prompt at your current location in Windows Explorer enter ''cmd'' in the location bar and hit ''Enter''. You can jump there quickly with either ''F4'' or ''Alt+D'' ==== Examples ==== * https://git-scm.com/docs/gitignore (docs) * https://github.com/raysan5/raylib/blob/master/.gitignore # comment *.ext file/path/ directory/ [Cc]ase === Specific useful things to ignore === So for [[gmt>Unity]] game you probably want to ignore those .pdb files. * https://gist.github.com/octocat/9257657 # Visual Studio / Unity *.pdb # Temp files *~ If you want to, as a base, ignore everything, then specifically tell it what to not-ignore: * https://stackoverflow.com/questions/987142/make-gitignore-ignore-everything-except-a-few-files#987162 * https://stackoverflow.com/questions/22896230/gitignore-everything-except-specific-files # ignores everything /* # except for... !/directory !file {{tag>cli guide software}}