put .gitignore in your main catalog
git status (you will see which files you can commit)
git add -A
git commit -m "message"
git push
Answer from Marcin Szymczak on Stack Overflow.gitignore for Eclipse CDT
git - Gitignore for Eclipse - Stack Overflow
Gitignore not working
eclipse - .gitignore for various IDEs - Salesforce Stack Exchange
Videos
put .gitignore in your main catalog
git status (you will see which files you can commit)
git add -A
git commit -m "message"
git push
You need to add your source files with git add or the GUI equivalent so that Git will begin tracking them.
Use git status to see what Git thinks about the files in any given directory.
I think the best solution is to generate .gitignore for yourself by gitignore.io.
Just choose tools that you used.
It depends on your requirement. Usually Compiled source,Packages, Logs and databases, Eclipse specific files/directories are removed from git push. Also can keep configuration in separate(property) file.It is easy to place project in a different environment.
This is a sample gitignore file
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #
############
# it's better to unpack these files and commit the raw source
# git has its own built in compression methods
*.7z
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar
*.zip
# Logs and databases #
######################
*.log
# OS generated files #
######################
.DS_Store*
ehthumbs.db
Icon?
Thumbs.db
# Editor Files #
################
*~
*.swp
# Gradle Files #
################
.gradle
.m2
# Build output directies #
##########################
/target
*/target
/build
*/build
# IntelliJ specific files/directories #
#######################################
out
.idea
*.ipr
*.iws
*.iml
atlassian-ide-plugin.xml
# Eclipse specific files/directories #
######################################
.classpath
.project
.settings
.metadata
# NetBeans specific files/directories #
#######################################
.nbattrs
Disclaimer: .gitignores tend to accumulate entries over time and never have them removed; they're kind of cargo-cult files. It is not a bad practice to start with a minimal .gitignore in your project, covering only the tools you know and use, and add new entries when you become aware that they're required!
Here's some examples sourced from the .gitignore from the Nonprofit Success Pack, a very long-lived project that has seen many IDEs come and go, as well as a couple of other Salesforce.org projects. NPSP is built using a stack that includes Node.js and Python tools as well.
I've elided some entries that are obsolete or that I cannot explain.
Eclipse is end-of-lifed. You shouldn't have to worry about it anymore - if anyone on your team is still using Eclipse, tell them to stop!
.DS_Store # Cruft from MacOS Finder
Thumbs.db # Cruft from Windows Explorer
.project # I think this is Eclipse but not certain
.settings # Ditto
salesforce.schema # Eclipse
Referenced Packages # Eclipse
build.properties # Force.com Migration Tool
/IlluminatedCloud # Illuminated Cloud
.idea/ # IntelliJ IDEA (Illuminated Cloud)
venv/ # Python
*.pyc # Python
.*.swp # Vim
*.sublime-project # Sublime Text (used with MavensMate)
*.sublime-workspace # Sublime Text (used with MavensMate)
.sfdx/ # SFDX
.vscode/ # Visual Studio Code
.cci/ # CumulusCI
node_modules/ # Node.js (LWC, Prettier)
coverage/ # LWC coverage information
.localdevserver/ # SFDX/LWC dev
- Open the terminal in Org folder & type
touch .gitignore - It will automatically create a gitignore for saleforce orgs
Or you can copy the following
# Salesforce cache
.sf/
.sfdx/
.localdevserver/
deploy-options.json
# LWC VSCode autocomplete
**/lwc/jsconfig.json
# LWC Jest coverage reports
coverage/
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Dependency directories
node_modules/
# Eslint cache
.eslintcache
# Visual Studio Code
.vscode/
# Windows system files
Thumbs.db
ehthumbs.db
[Dd]esktop.ini
$RECYCLE.BIN/
# Local environment variables
.env
For excluding configuration files you have to configure .gitignore to something as follows:
# Eclipse
.classpath
.project
.settings/
# Intellij
.idea/
*.iml
*.iws
# Mac
.DS_Store
# Maven
log/
target/
And, only after this, you have to push your project because now you have to push your configuration to the remote repo.
And you can not delete it locally and push. You have to delete it from remote repo only:
git rm --cached .project
For a directory:
git rm --cached -r target
One of my .gitignore files looks like this:
/bin
/.classpath
/.project
/.settings
/target
You can look at other projects at e.g. GitHub to let you inspire what you might want to put into your .gitignore, e.g.:
- https://github.com/spring-projects/spring-framework/blob/master/.gitignore
- https://github.com/spring-projects/spring-social/blob/master/.gitignore
However, I think my example above should be sufficient to start with.