You are currently viewing Do this before pushing code in Git.

Do this before pushing code in Git.

Don’t forget to add .gitIgnore file in IOS/Swift:-

If we are using git, you can simply make git ignore files to untrack files. For a .gitignore file, you should place it in the root folder of the repository. When making commits to any Git repository, you’ll choose the files you want to stage and then you’ll commit them.

But you might not want to commit every single one of your files—there are files that never need to get committed. This is where the .gitignore file is useful: it tells Git exactly which files to ignore and never track.

Let’s get started:-

What is gitignore?

You can create a .gitignore file in your repository’s root directory to tell Git which files and directories to ignore when you make a commit. To share the ignore rules with other users who clone the repository, commit the .gitignore file into your repository.

  1. Open Terminal.
  2. Navigate to the location of your Git repository.
  3. Create a .gitignore file for your repository.

The .gitignore file itself is a plain text document

  1. edit your .gitignore file

       Command:-   vim .gitignore

  1. Create a .gitignore file for your repository. (By pasting this command in terminal)

     Command:- touch .gitignore

     Note:- Project folder run (To show hidden files)

    Command :- Command + shift + .

.

The entries in this file can also follow a matching pattern.

  • * is used as a wildcard match
  • / is used to ignore pathnames relative to the .gitignore file
  • # is used to add comments to a .gitignore file

This is an example of what the .gitignore file could look like:

Some Important file ignore for iOS/swift : 

.DS_Store

*`.nib

*/DerivedData/

Build/

/xcuserdata/

DerivedData/

Packages/

ackage.pins

Package.resolved

Pods/

*.xcworkspace

Some Important file ignore for flutter : 

**/doc/api/

.dart_tool/

.flutter-plugins

.packages

.pub-cache/

.pub/

/build/

# Android related

 

**/android/**/gradle-wrapper.jar

**/android/.gradle

**/android/captures/

**/android/gradlew

**/android/gradlew.bat

**/android/local.properties

**/android/**/GeneratedPluginRegistrant.java

#Miscellaneous

*.class

*.log

*.pyc

*.swp

.DS_Store

.atom/

.buildlog/

.history

.svn/

How to Untrack Files Previously Committed from New Gitignore:-

To untrack a single file, ie stop tracking the file but not delete it from the system use:

Leave a Reply