to answer your title
NO
Simplest way to decide this would be to use the "official" .gitignore
for Unity from GitHub itself.
# This .gitignore file should be placed at the root of your Unity project directory
#
# Get latest from https://github.com/github/gitignore/blob/master/Unity.gitignore
#
/[Ll]ibrary/
/[Tt]emp/
/[Oo]bj/
/[Bb]uild/
/[Bb]uilds/
/[Ll]ogs/
/[Mm]emoryCaptures/
# Asset meta data should only be ignored when the corresponding asset is also ignored
!/[Aa]ssets/**/*.meta
# Uncomment this line if you wish to ignore the asset store tools plugin
# /[Aa]ssets/AssetStoreTools*
# Autogenerated Jetbrains Rider plugin
/[Aa]ssets/Plugins/Editor/JetBrains*
# Visual Studio cache directory
.vs/
# Gradle cache directory
.gradle/
# Autogenerated VS/MD/Consulo solution and project files
ExportedObj/
.consulo/
*.csproj
*.unityproj
*.sln
*.suo
*.tmp
*.user
*.userprefs
*.pidb
*.booproj
*.svd
*.pdb
*.mdb
*.opendb
*.VC.db
# Unity3D generated meta files
*.pidb.meta
*.pdb.meta
*.mdb.meta
# Unity3D generated file on crash reports
sysinfo.txt
# Builds
*.apk
*.unitypackage
# Crashlytics generated file
crashlytics-build.properties
As you can see the Library
folder is the very first thing ignored actually with good reason (see Iggy's answer).
possible exception
However personally it made sense to me to also keep the .asset
files from within the Library
folder. This is a bit inconvenient but here things like Buildsettings, TargetPlatform etc. are stored so you don't have to switch it manually everytime you clone.
So I always add this exception to .gitignore
!/[Ll]ibrary/*.asset
Read more about it in my answer to Cleaning up and Migrating existing Unity project into new one or another PC.
answering your actual issue
I don't know what kind of bugs you got with the TMP but you should not alter any code from packages at all!
As you noted this are only temporary changes if they are stored at all and not reverted immediately by the PackageManager!
From this post the official answer from Unity Technologies is
Yes, currently [May 22, 2019] the way to develop a package is to copy/move it [from the Library
folder] to your project's Packages
folder.
This converts the package into an embedded package which you now can alter and push together with the Packages
folder.